本文整理汇总了Python中driver.Driver.wakeup方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.wakeup方法的具体用法?Python Driver.wakeup怎么用?Python Driver.wakeup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类driver.Driver
的用法示例。
在下文中一共展示了Driver.wakeup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Connection
# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import wakeup [as 别名]
#.........这里部分代码省略.........
self.reconnect_limit = options.get("reconnect_limit")
self.reconnect_urls = options.get("reconnect_urls", [])
self.reconnect_log = options.get("reconnect_log", True)
self.address_ttl = options.get("address_ttl", 60)
self.tcp_nodelay = options.get("tcp_nodelay", False)
self.ssl_keyfile = options.get("ssl_keyfile", None)
self.ssl_certfile = options.get("ssl_certfile", None)
self.ssl_trustfile = options.get("ssl_trustfile", None)
self.ssl_skip_hostname_check = options.get("ssl_skip_hostname_check", False)
self.client_properties = options.get("client_properties", {})
self.options = options
self.id = str(uuid4())
self.session_counter = 0
self.sessions = {}
self._open = False
self._connected = False
self._transport_connected = False
self._lock = RLock()
self._condition = Condition(self._lock)
self._waiter = Waiter(self._condition)
self._modcount = Serial(0)
self.error = None
from driver import Driver
self._driver = Driver(self)
def _wait(self, predicate, timeout=None):
return self._waiter.wait(predicate, timeout=timeout)
def _wakeup(self):
self._modcount += 1
self._driver.wakeup()
def check_error(self):
if self.error:
self._condition.gc()
e = self.error
if isinstance(e, ContentError):
""" forget the content error. It will be
raised this time but won't block future calls
"""
self.error = None
raise e
def get_error(self):
return self.error
def _ewait(self, predicate, timeout=None):
result = self._wait(lambda: self.error or predicate(), timeout)
self.check_error()
return result
def check_closed(self):
if not self._connected:
self._condition.gc()
raise ConnectionClosed()
@synchronized
def session(self, name=None, transactional=False):
"""
Creates or retrieves the named session. If the name is omitted or
None, then a unique name is chosen based on a randomly generated
示例2: open
# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import wakeup [as 别名]
class Connection:
"""
A Connection manages a group of L{Sessions<Session>} and connects
them with a remote endpoint.
"""
@static
def open(host, port=None, username="guest", password="guest",
mechanism="PLAIN", heartbeat=None, **options):
"""
Creates an AMQP connection and connects it to the given host and port.
@type host: str
@param host: the name or ip address of the remote host
@type port: int
@param port: the port number of the remote host
@rtype: Connection
@return: a connected Connection
"""
conn = Connection(host, port, username, password, mechanism, heartbeat, **options)
conn.connect()
return conn
def __init__(self, host, port=None, username="guest", password="guest",
mechanism="PLAIN", heartbeat=None, **options):
"""
Creates a connection. A newly created connection must be connected
with the Connection.connect() method before it can be used.
@type host: str
@param host: the name or ip address of the remote host
@type port: int
@param port: the port number of the remote host
@rtype: Connection
@return: a disconnected Connection
"""
self.host = host
self.port = default(port, AMQP_PORT)
self.username = username
self.password = password
self.mechanism = mechanism
self.heartbeat = heartbeat
self.id = str(uuid4())
self.session_counter = 0
self.sessions = {}
self.reconnect = options.get("reconnect", False)
self._connected = False
self._lock = RLock()
self._condition = Condition(self._lock)
self._waiter = Waiter(self._condition)
self._modcount = Serial(0)
self.error = None
from driver import Driver
self._driver = Driver(self)
self._driver.start()
def _wait(self, predicate, timeout=None):
return self._waiter.wait(predicate, timeout=timeout)
def _wakeup(self):
self._modcount += 1
self._driver.wakeup()
def _check_error(self, exc=ConnectionError):
if self.error:
raise exc(*self.error)
def _ewait(self, predicate, timeout=None, exc=ConnectionError):
result = self._wait(lambda: self.error or predicate(), timeout)
self._check_error(exc)
return result
@synchronized
def session(self, name=None, transactional=False):
"""
Creates or retrieves the named session. If the name is omitted or
None, then a unique name is chosen based on a randomly generated
uuid.
@type name: str
@param name: the session name
@rtype: Session
@return: the named Session
"""
if name is None:
name = "%s:%s" % (self.id, self.session_counter)
self.session_counter += 1
else:
name = "%s:%s" % (self.id, name)
if self.sessions.has_key(name):
return self.sessions[name]
else:
ssn = Session(self, name, transactional)
self.sessions[name] = ssn
self._wakeup()
return ssn
#.........这里部分代码省略.........