本文整理汇总了Python中twisted.internet.protocol.ClientFactory.clientConnectionFailed方法的典型用法代码示例。如果您正苦于以下问题:Python ClientFactory.clientConnectionFailed方法的具体用法?Python ClientFactory.clientConnectionFailed怎么用?Python ClientFactory.clientConnectionFailed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol.ClientFactory
的用法示例。
在下文中一共展示了ClientFactory.clientConnectionFailed方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
self.clientProxy.nodeLocator.remove(self.address)
if hasattr(self, 'deferred') and not self.deferred.called:
self.reactor.callLater(0, self.deferred.errback, reason)
del self.deferred
ClientFactory.clientConnectionFailed(
self, connector, reason)
示例2: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
logger.info('connection failed: %s', reason.getErrorMessage())
ClientFactory.clientConnectionFailed(self, connector, reason)
if self.reconnect:
time.sleep(self.reconnect_delay)
connector.connect()
elif not self.protocols:
if self.onFinish:
self.onFinish.callback(None)
示例3: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
logging.info('Connection failed')
ClientFactory.clientConnectionFailed(self, connector, reason)
#If first connection was failed - try to start server
if not self.reconnect:
#Start, reconnect
try:
subprocess.Popen(['python', 'server.py']).wait()
except Exception, err:
logging.exception('Error starting server: %s', err)
time.sleep(3)
do_connect(self.listener, True)
示例4: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
logger.info('connection failed: {}'.format(reason))
ClientFactory.clientConnectionFailed(self, connector, reason)
if self.reconnect:
reactor.callFromThread(time.sleep, self.reconnect_delay)
connector.connect()
else:
if self.standalone:
try:
reactor.callFromThread(reactor.stop)
except ReactorNotRunning:
pass
示例5: connect
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def connect(self, host, port):
self._connection_timeout = self.timeout
self._stack_conn = _Connection()
self._stack_conn.attach(self)
self._stack_conn.connect_cb = Callback()
factory = ClientFactory()
factory.protocol = lambda: self._stack_conn
factory.clientConnectionFailed = self.clientConnectionFailed
self._connect_to_reactor(host, port, factory, self._connection_timeout)
yield self._stack_conn.connect_cb
示例6: connect
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def connect(self, host, port):
self._stack_conn = _Connection()
self._stack_conn.attach(self)
self._stack_conn.connect_cb = Callback()
factory = ClientFactory()
factory.protocol = lambda: self._stack_conn
factory.clientConnectionFailed = self.clientConnectionFailed
if self.ssl_options is not None:
reactor.connectSSL(host, port, factory,
SSLContextFactory(self.ssl_options))
else:
reactor.connectTCP(host, port, factory)
yield self._stack_conn.connect_cb
示例7: getYobotPurpleFactory
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def getYobotPurpleFactory(self):
f = ClientFactory()
f.protocol = YobotPurple
f.setPurple = self.setPurple
f.doRegister = self.purpleDoRegister
f.dispatch = self.purple_dispatch
#...
f.attempts = 0
max_attempts = 5
def clientConnectionFailed(connector, reason):
log_err("Attempt %d/%d failed: %s" % (f.attempts, max_attempts, reason))
if f.attempts < max_attempts:
log_info("trying again in 1.5 secs")
reactor.callLater(1.5, connector.connect)
f.attempts += 1
f.clientConnectionFailed = clientConnectionFailed
return f
示例8: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
log.err(reason, 'Connection failed')
ClientFactory.clientConnectionFailed(self, connector, reason)
示例9: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
""" """
print 'client connection failed'
ClientFactory.clientConnectionFailed(self, connector, reason)
self.controller.completed.errback(reason)
示例10: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
ClientFactory.clientConnectionFailed(self, connector, reason)
e = Event('connection-result', succeeded = False, reason = reason)
self.event_func(e)
示例11: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
logger.debug("%s: BaseClient::clientConnectionFailed(): %s",
self.protocol_name, reason)
self.session = None
return ClientFactory.clientConnectionFailed(self, connector, reason)
示例12: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
self.log_error("Unable to connect to APN feedback server: %s" %
(reason,))
self.connected = False
ClientFactory.clientConnectionFailed(self, connector, reason)
示例13: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
ClientFactory.clientConnectionFailed(self, connector, reason)
示例14: clientConnectionFailed
# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import clientConnectionFailed [as 别名]
def clientConnectionFailed(self, connector, reason):
print "serverConnectionFailed", reason
ClientFactory.clientConnectionFailed(self, connector, reason)
self.controller.completed.errback(reason)