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
def connectionLost( self, reason ): Protocol.connectionLost( self, reason ) self.log.warning("Disconnected: %s" % reason) #self.sessionState = JT808SessionStates.NONE if self.termPhone in self.factory.clients: self.factory.clients.pop(self.termPhone) self.disconnectedDeferred.callback(None)
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_RELAYER: InternalMessage.UnregistFilter(InternalMessage.TTYPE_GATEWAY, self.relayer_id) InternalMessage.NotifyTerminalStatus(InternalMessage.TTYPE_GATEWAY, self.relayer_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)
def connectionLost(self, reason): print self.name self.factory.mzcall(self.name,False) Protocol.connectionLost(self, reason) self.stop() print "locst connection:",reason self.factory.number_of_connections -= 1 print "number_of_connections:",self.factory.number_of_connections
def connectionLost(self, reason=None): g_logger.info( "Gate Callback connection lost. Disconnecting higher protocol") if self.higherProtocol(): self.higherProtocol().connectionLost(reason) self.setHigherProtocol(None) self.factory.unregisterCallbackProtocol(self) Protocol.connectionLost(self, reason)
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)
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)
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)
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.log.warning("SMPP %s disconnected from port %s: %s", self.transport.getPeer().host, self.port, reason) self.sessionState = SMPPSessionStates.NONE self.cancelEnquireLinkTimer() self.cancelInactivityTimer() self.disconnectedDeferred.callback(None)
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)
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)
def connectionLost(self, *args, **kwargs): global _WebSocketTransports if _Debug: lg.args(_DebugLevel, key=self._key, ws_connections=len(_WebSocketTransports)) Protocol.connectionLost(self, *args, **kwargs) _WebSocketTransports.pop(self._key) peer = '%s://%s:%s' % (self._key[0], self._key[1], self._key[2]) self._key = None events.send('web-socket-disconnected', data=dict(peer=peer))
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
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))
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)
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))
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)
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)
def connectionLost(self, reason=error.ConnectionDone): Protocol.connectionLost(self, reason=reason)
def connectionLost(self, reason=connectionDone): with self.__lock: self.__connected = False #self.__stateChangeListener.connectionLost(reason) Protocol.connectionLost(self, reason)
def connectionLost(self, *args, **kwargs): Protocol.connectionLost(self, *args, **kwargs) global _WebSocketTransport _WebSocketTransport = None events.send('web-socket-disconnected', data=dict())
def connectionLost(self, reason=ConnectionDone): Protocol.connectionLost(self, reason=reason) self.higherProtocol().connectionLost(reason) self.higherProtocol().transport = None self.setHigherProtocol(None)
def connectionLost(self, reason): self.kaService.stopService() Protocol.connectionLost(self, reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.term.stop()
def _receive(response, url, headers, follow_redirect, redirect_history): d = Deferred() headers = dict(response.headers.getAllRawHeaders()) code = response.code length = response.length # check for redirects if follow_redirect and (code == 302 or code == 301): try: redirect = headers['Location'][0] except KeyError: raise CorruptRedirect, 'Received redirect response without Location header' parts = list(urlparse(redirect)) original_parts = list(urlparse(url)) if parts[0]=='': parts[0] = original_parts[0] if parts[1]=='': parts[1] = original_parts[1] redirect = urlunparse(parts) if code==301: _permanent_redirects[url] = redirect if redirect_history is None: redirect_history = () # comes from post, don't add as history else: redirect_history = redirect_history + (url,) if redirect in redirect_history: raise CyclicRedirect, 'Next url has already been in the redirects cycle: ' + redirect return get(redirect, headers, True, redirect_history) body = [''] last_modified = None # common closure def close(_): response = Response(code, body[0], headers, url, redirect_history) if last_modified is not None: _cache[url] = (last_modified, body[0]) d.callback(response) # check for not modified: if code == 304: body[0] = _cache[url][1] reactor.callLater(0, close, None) return d # check for caching if 'Last-Modified' in headers: last_modified = headers['Last-Modified'][0] if length == 0: reactor.callLater(0, close, None) return d # retrieve body def _receiveChunk(chunk): body[0] = body[0] + chunk bodyReceiver = Protocol() bodyReceiver.dataReceived = _receiveChunk bodyReceiver.connectionLost = close response.deliverBody(bodyReceiver) return d
def connectionLost(self, reason=ConnectionDone): Protocol.connectionLost(self, reason=reason) LOG.warn('Lost connection.\n\tReason:{}'.format(reason))
def connectionLost(self, reason): try: self._onConnectionLost(reason) finally: Protocol.connectionLost(self, reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.log.debug("Connection lost.") self.engine.unbind()
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.factory.number_of_connections -= 1
def connectionLost(self, reason): try: self._onConnectionLost(reason) finally: Protocol.connectionLost(self, reason)
def connectionLost(self, reason): '''Remove connection from list. >>> factory = factory_mock() >>> ethan = protocol_mock(factory) Even if serial number not connected, gracefully disconnect. >>> ethan.factory.connections.has_key(ethan.connection_serial) False >>> ethan.connectionLost('[closed cleanly]') connectionLost: error None not connected [] Expect to connect before disconnect. >>> ethan.connectionMade() transport.write(40) >>> ethan.connection_serial 0 >>> ethan.factory.connections.has_key(ethan.connection_serial) True >>> ethan.connectionLost('[closed cleanly]') Even if serial number not connected, gracefully disconnect. >>> ethan.connectionLost('[closed cleanly]') connectionLost: error 0 not connected [0] >>> ethan.factory.connections.has_key(ethan.connection_serial) True Ethan and Wout connect, and take a number in order. >>> ethan = protocol_mock(factory) >>> ethan.connectionMade() transport.write(40) >>> ethan.connection_serial 1 >>> wout = protocol_mock(factory) >>> wout.connectionMade() transport.write(40) >>> wout.connection_serial 2 Ethan disconnects. Wout keeps his number. >>> ethan.connectionLost('[closed cleanly]') >>> wout.connection_serial 2 Ethan reconnects on next number. >>> ethan = protocol_mock(factory) >>> ethan.connectionMade() transport.write(40) >>> ethan.connection_serial 3 >>> wout.connection_serial 2 >>> wout.connectionLost('[closed cleanly]') >>> ethan.connectionLost('[closed cleanly]') ''' disconnect_note = ' disconnected %s because %s' \ % (self.connection_serial, reason) logging.info(disconnect_note) Protocol.connectionLost(self, reason) if self.connection_serial in self.factory.connections \ and self.factory.connections[self.connection_serial]: self.factory.connections[self.connection_serial] = None else: error = 'connectionLost: error %s not connected %s' \ % (self.connection_serial, self.factory.connections.keys()) logging.error(error) print error self.on_disconnect(reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.term.stop()
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.factory.number_of_connections -= 1
def connectionLost(self, reason): self.isconnected = False if self.debug: log.msg("connectionLost") Protocol.connectionLost(self, reason)
def connectionLost(self, reason=ConnectionDone): """ TearDown """ Protocol.connectionLost(self, reason=reason) LOG.warn('Lost connection.\n\tReason:{}'.format(reason))
def connectionLost(self, reason): self.connected = False return Protocol.connectionLost(self, reason)
def connectionLost(self, reason=error.ConnectionDone): LOG.debug('Connection Lost. {}'.format(reason)) Protocol.connectionLost(self, reason=reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason) if self.player: print "* Tofu * Connection lost with player %s:" % self.player.filename, reason.getErrorMessage() self.logout_player()
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.stop() print("locst connection:", reason) self.factory.number_of_connections -= 1 print("number_of_connections:", self.factory.number_of_connections)
def connectionLost(self, reason=None): Protocol.connectionLost(self) self.higherProtocol().transport = None self.higherProtocol().connectionLost(reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason=reason) self.curState=ProtocolState.CO_NO
def connectionLost(self, reason): return Protocol.connectionLost(self, reason)
def connectionLost(self, reason=twistedError.ConnectionDone): Protocol.connectionLost(self, reason=reason) print "connection lost:",id(self.transport),reason
def connectionLost(self, reason): self._disconnected = True self._cancelCommands(reason) Protocol.connectionLost(self, reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason) self.log.debug("Connection lost.") self.engine.unbind()
def connectionLost(self, *args): ep = self.transport.getPeer() self.session = self.theater.DeleteSession(ep.host, ep.port) Protocol.connectionLost(self, *args)
def connectionLost(self, reason=twistedError.ConnectionDone): Protocol.connectionLost(self, reason=reason) print("connection lost:", id(self.transport), reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason=reason)
def connectionLost(self, reason=None): print "Connection lost", reason Protocol.connectionLost(self, reason=reason) self.control.endTest(self, reason)
def connectionLost(self, reason=connectionDone): Protocol.connectionLost(self, reason=reason) self.closer()
def connectionLost(self, reason=connectionDone): """Override Twisted event callback.""" logger.debug("%s: BaseServerSession::connectionLost(): %s", self.protocol_name, reason) return Protocol.connectionLost(self, reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason) print "connectionLost", repr(reason)
def connectionLost(self,reason): Protocol.connectionLost(self,reason) #客户端没断开一个链接,总连接数-1 print 'Lost Client:',reason.getErrorMessage() self.factory.number_of_connections -= 1 print "Number_of_connections:",self.factory.number_of_connections
def connectionLost(self, reason=connectionDone): print "Lost connection to client. Cleaning up." Protocol.connectionLost(self, reason=reason)
def connectionLost(self, reason): return Protocol.connectionLost(self, reason)
def connectionLost(self, reason): Protocol.connectionLost(self, reason)
def deliver_body(p: Protocol): p.dataReceived(body) p.connectionLost(Failure(twisted.web.client.ResponseDone()))
def connectionLost(self, reason): Protocol.connectionLost(self, reason) if not reason.check(ConnectionDone): print("connectionLost", repr(reason))