python类connectionDone()的实例源码

test_protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_connectionLost_clientClose(self):
        '''If connectionLost is called because the client closed the
        connection, then this connection has disappeared suddenly.
        Consequently, the protocol's terminationDeferred errbacks with
        the provided reason, the timeout clock is stopped, and the
        session machine learns about the lost connection.

        '''
        erroredDeferred = self.protocol.terminationDeferred

        def trapConnectionDone(failure):
            failure.trap(error.ConnectionDone)

        erroredDeferred.addErrback(trapConnectionDone)

        self.protocol.connectionLost(connectionDone)

        self.assertEqual(self.timeoutClockRecorder.stopCalls, 1)
        self.assertEqual(self.sessionMachineRecorder.connectionsLostReasons,
                         [connectionDone])
        self.assertIsNone(self.protocol.sessionMachine)

        return erroredDeferred
sse_protocol.py 文件源码 项目:marathon-acme 作者: praekeltfoundation 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=connectionDone):
        self.log.failure('SSE connection lost', reason, LogLevel.warn)
        self.setTimeout(None)  # Cancel the timeout
        for d in list(self._waiting):
            d.callback(None)
        self._waiting = []
session.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def loseConnection(self):
        self.proto.connectionLost(protocol.connectionDone)
smtp.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        """We are no longer connected"""
        self.setTimeout(None)
        self.mailFile = None
command.py 文件源码 项目:onkyo_serial 作者: blaedd 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        self.factory.remove_cb(self)
iscp.py 文件源码 项目:onkyo_serial 作者: blaedd 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        self.factory.remove_cb(self)
twisted_client.py 文件源码 项目:ircproto 作者: agronholm 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=connectionDone):
        reactor.stop()
session.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def loseConnection(self):
        self.proto.connectionLost(protocol.connectionDone)
smtp.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        """We are no longer connected"""
        self.setTimeout(None)
        self.mailFile = None
pcom_serial.py 文件源码 项目:Parlay 作者: PromenadeSoftware 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=connectionDone):
        """
        Overridden function that is called when the connected port is disconnected. Simply sets the
        self.is_port_attached flag to False so that we know we have been disconnected from the target embedded
        board.
        :param reason: Reason for disconnection. Of Twisted failure type.
        :return:
        """
        self.is_port_attached = False
        LineReceiver.connectionLost(self, reason)
bridge.py 文件源码 项目:matrix-appservice-gitter-twisted 作者: remram44 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=connectionDone):
        log.info("Lost stream for user {user} room {room}",
                 user=self.user.github_username, room=self.gitter_room_name)
        self.stream_response = None
        if not self.destroyed:
            gitter_stream_limit.schedule(self.start_stream)
utils.py 文件源码 项目:matrix-appservice-gitter-twisted 作者: remram44 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=connectionDone):
        if not self.finished.called:
            self.finished.callback(self.content.getvalue())
irc.py 文件源码 项目:joinmarket-clientserver 作者: JoinMarket-Org 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        if self.wrapper.on_disconnect:
            reactor.callLater(0.0, self.wrapper.on_disconnect, self.wrapper)
        return irc.IRCClient.connectionLost(self, reason)
gssapiprotocol.py 文件源码 项目:treadmill 作者: Morgan-Stanley 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        """Callback invoked on connection lost."""
        _LOGGER.info('connection lost')
session.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def loseConnection(self):
        self.proto.connectionLost(protocol.connectionDone)
smtp.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        """
        We are no longer connected
        """
        self.setTimeout(None)
        self.mailFile = None
test_protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_beginRequest_finishedNotifier_forwards_failures(self):
        '''Beginning a request retrieves a Deferred from that request that
        forwards failures to the protocol's connectionLost.

        '''
        self.protocol.request = self.request
        self.protocol.beginRequest()

        reason = connectionDone

        def assertConnectionLostCalled(ignored):
            recordedExceptions = [
                reason.value for reason in
                self.sessionMachineRecorder.connectionsLostReasons]
            self.assertEqual(recordedExceptions, [reason.value])

        finishedNotifier = self.protocol.finishedNotifier
        finishedNotifier.addCallback(assertConnectionLostCalled)

        def trapConnectionDone(failure):
            failure.trap(error.ConnectionDone)

        terminationDeferred = self.protocol.terminationDeferred
        terminationDeferred.addErrback(trapConnectionDone)

        self.request.processingFailed(reason)
        return DeferredList([finishedNotifier, terminationDeferred])
test_protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_completeConnectionLost(self):
        '''Completing a lost connection calls the wrapped protocol's
        connectionLost.

        '''
        self.request.transport = StringTransport()
        self.protocol.establishConnection(self.request)
        self.protocol.completeConnectionLost(connectionDone)
        self.assertEqual(self.connectionsLost, [connectionDone])
test_protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_timedOutCallback(self):
        '''The termination deferred's callback sets disconnecting and calls
        connectionLost.  Setting disconnecting avoids errbacking the
        deferred that's just been fired!

        '''
        terminationDeferred = self.protocol.terminationDeferred

        def assertConnectionLostCalled(ignored):
            self.assertTrue(self.protocol.disconnecting)
            self.assertEqual(self.sessionMachineRecorder.connectionsLost,
                             connectionDone)

        terminationDeferred.callback(P.TimeoutClock.EXPIRED)
        return terminationDeferred
test_protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_sessionClosed_on_errback(self):
        '''Errbacking the protocol's terminationDeferred removes the session
        from the house.

        '''
        self.test_attachToSession_new_session()
        self.protocol.terminationDeferred.errback(connectionDone)
        self.assertNotIn(self.sessionID, self.sessions.sessions)
        return self.protocol.terminationDeferred
protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        '''The connection has been lost; clean up any request and clean up the
        protocol.

        '''
protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _dropRequest(self, reason=protocol.connectionDone):
        self.requestSession.request = None
protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def _closeProtocol(self, reason=protocol.connectionDone):
        self.requestSession.completeConnectionLost(reason)
        self.requestSession = None
protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _timedOut(self, reason=protocol.connectionDone):
        if isinstance(reason.value, error.ConnectionDone):
            reason = failure.Failure(SessionTimeout())
        self.requestSession.completeConnectionLost(reason=reason)
        self.requestSession = None
protocol.py 文件源码 项目:txdarn 作者: markrwilliams 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        if not self.disconnecting:
            self.terminationDeferred.errback(reason)
            self.timeoutClock.stop()
        self.sessionMachine.connectionLost(reason)
        self.sessionMachine = None
ssh.py 文件源码 项目:duct 作者: ducted 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=protocol.connectionDone):
        self.stdOut.seek(0)
        self.stdErr.seek(0)
        if reason.type is error.ConnectionDone:
            # Success
            code = 0
        else:
            code = reason.value.exitCode
        self.factory.done.callback((self.stdOut, self.stdErr, code))
listener.py 文件源码 项目:pokelector 作者: Kostronor 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=connectionDone):
        self.session.commit()
        self.session.close()
        self.update_tick(dot='-')
test_common.py 文件源码 项目:maas 作者: maas 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_onConnectionLost_fires_when_connection_is_lost(self):
        protocol = common.RPCProtocol()
        protocol.makeConnection(StringTransport())
        protocol.connectionLost(connectionDone)
        self.assertThat(protocol.onConnectionLost, IsFiredDeferred())
p2pprotocol.py 文件源码 项目:QRL 作者: theQRL 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def connectionLost(self, reason=connectionDone):
        logger.info('%s disconnected. remainder connected: %s',
                    self.transport.getPeer().host,
                    str(self.factory.connections))  # , reason
        try:
            self.factory.peer_connections.remove(self)

            if self.factory.connections == 0:
                reactor.callLater(60, self.factory.connect_peers)

            # FIXME: unsafe access to synced_peers
            if self in self.factory.synced_peers:
                self.factory.synced_peers.remove(self)
        except Exception:
            pass


问题


面经


文章

微信
公众号

扫码关注公众号