本文整理汇总了Python中pika.adapters.BaseConnection._adapter_connect方法的典型用法代码示例。如果您正苦于以下问题:Python BaseConnection._adapter_connect方法的具体用法?Python BaseConnection._adapter_connect怎么用?Python BaseConnection._adapter_connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pika.adapters.BaseConnection
的用法示例。
在下文中一共展示了BaseConnection._adapter_connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _adapter_connect
# 需要导入模块: from pika.adapters import BaseConnection [as 别名]
# 或者: from pika.adapters.BaseConnection import _adapter_connect [as 别名]
def _adapter_connect(self, host, port):
BaseConnection._adapter_connect(self, host, port)
self.socket.setblocking(1)
self.socket.settimeout(SOCKET_TIMEOUT)
self._socket_timeouts = 0
self._on_connected()
while not self.is_open:
self._flush_outbound()
self._handle_read()
return self
示例2: _adapter_connect
# 需要导入模块: from pika.adapters import BaseConnection [as 别名]
# 或者: from pika.adapters.BaseConnection import _adapter_connect [as 别名]
def _adapter_connect(self):
BaseConnection._adapter_connect(self)
self.socket.setblocking(1)
# Set the timeout for reading/writing on the socket
self.socket.settimeout(SOCKET_TIMEOUT)
self._socket_timeouts = 0
self._on_connected()
while not self.is_open:
self._flush_outbound()
self._handle_read()
return self
示例3: _adapter_connect
# 需要导入模块: from pika.adapters import BaseConnection [as 别名]
# 或者: from pika.adapters.BaseConnection import _adapter_connect [as 别名]
def _adapter_connect(self):
BaseConnection._adapter_connect(self)
self.socket.setblocking(1)
# Set the timeout for reading/writing on the socket
self.socket.settimeout(self.parameters.socket_timeout)
self._socket_timeouts = 0
self._on_connected()
self._timeouts = dict()
# When using a high availability cluster (such as HAProxy) we are always able to connect
# even though there might be no RabbitMQ backend.
socket_timeout_retries = 0
while not self.is_open and socket_timeout_retries<SOCKET_TIMEOUT_THRESHOLD:
self._flush_outbound()
self._handle_read()
socket_timeout_retries +=1
if not self.is_open:
raise AMQPConnectionError("No connection could be opened after %s retries" % SOCKET_TIMEOUT_THRESHOLD)
return self