本文整理汇总了Python中twisted.internet.protocol.Protocol.connectionLost方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.connectionLost方法的具体用法?Python Protocol.connectionLost怎么用?Python Protocol.connectionLost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.connectionLost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason):
Protocol.connectionLost(self, reason)
self.started = False
self.factory.number_of_connections -= 1
self.player = None
print "lost"
print "Current number of connections:", self.factory.number_of_connections
示例2: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason):
# remove from channel and disconnect, reset state machine
if self in self.factory.channels[self.channel]:
self.factory.channels[self.channel].remove(self)
if self.factory.channels[self.channel].count <= 0:
del self.factory.channels[self.channel]
self.curState=ProtocolState.CO_NO
self.factory.notifyObservers("A dude left the channel", self.channel)
Protocol.connectionLost(self, reason=reason)
示例3: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason = connectionDone):
log.info('SyncAnyProtocol::connectionLost')
self.started = False
Protocol.connectionLost(self, reason)
#self.factory.clients.remove(self)
if not self.user is None:
self.factory.clients.removeClient(self)
示例4: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason):
#print "CONNECTIONLOST"
#MultiBufferer.connectionLost(self, reason)
# XXX When we call MultiBufferer.connectionLost, we get
# unhandled errors (something isn't adding an Errback
# to the deferred which eventually gets GC'd, but I'm
# not *too* worried because it *does* get GC'd).
# Do check that the things which yield on read() on
# the multibufferer get correctly GC'd though.
Protocol.connectionLost(self, reason)
示例5: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason=ResponseDone):
"""
overload Protocol.connectionLost to handle disconnect
"""
Protocol.connectionLost(self, reason)
if reason.check(ResponseDone):
self._deferred.callback(True)
else:
log.err("ResponseProducerProtocol connection lost %s" % (reason, ),
logLevel=logging.ERROR)
self._deferred.errback(reason)
示例6: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason=connectionDone):
"""Abort any outstanding requests when we lose our connection."""
Protocol.connectionLost(self, reason)
requests = self.requests.values()
for request in requests:
request.stopProducing()
if request.started:
request.cancel()
try:
# also removes from self.requests
request.error(reason)
except defer.AlreadyCalledError:
# cancel may already have error-ed the request
continue
示例7: reconnector
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def reconnector(self, onion):
protocol = Protocol()
protocol.onion = onion
protocol.connectionLost = lambda failure: self.handleLostConnection(failure, onion)
tor_endpoint = clientFromString(self.reactor, "tor:%s.onion:8060" % onion)
self.onion_pending_map[onion] = connectProtocol(tor_endpoint, protocol)
self.onion_pending_map[onion].addCallback(lambda protocol: self.connection_ready(onion, protocol))
self.onion_pending_map[onion].addErrback(lambda failure: self.connectFail(failure, onion))
示例8: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason=connectionDone):
#logger.debug("connectionLost(): %s", str(reason))
logger.debug("connectionLost(): %s port %s to %s:%s %s%s",
self.factory.name,
self.factory.local_port,
self.factory.host, self.factory.port,
self.protocol_name,
"" if type(reason) == ConnectionDone else ": %s" % str(reason))
return Protocol.connectionLost(self, reason)
示例9: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason):
"""When TCP connection is lost, remove shutdown handler
"""
if reason.type == ConnectionLost:
msg = 'Disconnected'
else:
msg = 'Disconnected: %s' % reason.getErrorMessage()
self.log.debug(msg)
#Remove connect timeout if set
if self.connectTimeoutDelayedCall is not None:
self.log.debug('Cancelling connect timeout after TCP connection was lost')
self.connectTimeoutDelayedCall.cancel()
self.connectTimeoutDelayedCall = None
#Callback for failed connect
if self.connectedDeferred:
if self.connectError:
self.log.debug('Calling connectedDeferred errback: %s' % self.connectError)
self.connectedDeferred.errback(self.connectError)
self.connectError = None
else:
self.log.error('Connection lost with outstanding connectedDeferred')
error = StompError('Unexpected connection loss')
self.log.debug('Calling connectedDeferred errback: %s' % error)
self.connectedDeferred.errback(error)
self.connectedDeferred = None
#Callback for disconnect
if self.disconnectedDeferred:
if self.disconnectError:
#self.log.debug('Calling disconnectedDeferred errback: %s' % self.disconnectError)
self.disconnectedDeferred.errback(self.disconnectError)
self.disconnectError = None
else:
#self.log.debug('Calling disconnectedDeferred callback')
self.disconnectedDeferred.callback(self)
self.disconnectedDeferred = None
Protocol.connectionLost(self, reason)
示例10: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason=twistedError.ConnectionDone):
if self.role == Command.BaseCommand.PV_ROLE_HUMAN:
InternalMessage.UnregistFilter(InternalMessage.TTYPE_HUMAN, self.client_id)
InternalMessage.NotifyTerminalStatus(
InternalMessage.TTYPE_HUMAN, self.client_id, id(self.transport), InternalMessage.OPER_OFFLINE, "n"
)
elif self.role == Command.BaseCommand.PV_ROLE_SUPERBOX:
InternalMessage.UnregistFilter(InternalMessage.TTYPE_GATEWAY, self.superbox_id)
InternalMessage.NotifyTerminalStatus(
InternalMessage.TTYPE_GATEWAY, self.superbox_id, 0, InternalMessage.OPER_OFFLINE
)
try:
self.timer.cancel()
except Exception:
pass
# print "connection lost:",id(self.transport),reason
self.releaseFromDict()
with self.factory.lockPendingCmd:
SBProtocol.connection_count = SBProtocol.connection_count - 1
Protocol.connectionLost(self, reason=reason)
示例11: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason):
Protocol.connectionLost(self, reason)
self.log.debug("Connection lost.")
self.engine.unbind()
示例12: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason=error.ConnectionDone):
Protocol.connectionLost(self, reason=reason)
示例13: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason):
Protocol.connectionLost(self, reason=reason)
self.curState=ProtocolState.CO_NO
示例14: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason=ConnectionDone):
Protocol.connectionLost(self, reason=reason)
LOG.warn('Lost connection.\n\tReason:{}'.format(reason))
示例15: connectionLost
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import connectionLost [as 别名]
def connectionLost(self, reason):
Protocol.connectionLost(self, reason)
self.factory.number_of_connections -= 1