Python twisted.internet.protocol.connectionDone() Examples

The following are 23 code examples of twisted.internet.protocol.connectionDone(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module twisted.internet.protocol , or try the search function .
Example #1
Source File: policy_server.py    From treadmill with Apache License 2.0 6 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """Handle a disconnect from a client.
        """
        super().connectionLost(reason)
        session = self._session
        if session is not None:
            _LOGGER.info('Terminating session %08x', session['id'])
            _utils.wg_dev_delete(session['interface'])
            session_name = _session_fname(session)
            session_network = self._networks[session['network']]
            session_network['pool'].free(
                owner=session_name,
                owned_ip=session['client_ip']
            )
            fs.rm_safe(
                os.path.join(self._sessions_dir, session_name)
            )
            self._session = None 
Example #2
Source File: tcp.py    From pyrdp with GNU General Public License v3.0 5 votes vote down vote up
def connection_lost(self, exception=connectionDone):
        """
        :param exception: reason for disconnection.
        """
        self.observer.onDisconnection(exception) 
Example #3
Source File: test_common.py    From maas with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_onConnectionLost_fires_when_connection_is_lost(self):
        protocol = common.RPCProtocol()
        protocol.makeConnection(StringTransport())
        protocol.connectionLost(connectionDone)
        self.assertThat(protocol.onConnectionLost, IsFiredDeferred()) 
Example #4
Source File: lineserver.py    From treadmill with Apache License 2.0 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """Callback invoked on connection lost."""
        _LOGGER.info('connection lost')
        self._ctx = None 
Example #5
Source File: peercredprotocol.py    From treadmill with Apache License 2.0 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """Callback invoked on connection lost."""
        _LOGGER.info('connection lost') 
Example #6
Source File: irc.py    From joinmarket-clientserver with GNU General Public License v3.0 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        wlog("INFO", "Lost IRC connection to: " + str(self.hostname)
            + " . Should reconnect automatically soon.")
        if self.wrapper.on_disconnect:
            reactor.callLater(0.0, self.wrapper.on_disconnect, self.wrapper)
        return irc.IRCClient.connectionLost(self, reason) 
Example #7
Source File: session.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def loseConnection(self):
        self.proto.connectionLost(protocol.connectionDone) 
Example #8
Source File: smtp.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """We are no longer connected"""
        self.setTimeout(None)
        self.mailFile = None 
Example #9
Source File: session.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def loseConnection(self):
        self.proto.connectionLost(protocol.connectionDone) 
Example #10
Source File: smtp.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """We are no longer connected"""
        self.setTimeout(None)
        self.mailFile = None 
Example #11
Source File: p2pprotocol.py    From QRL with MIT License 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        logger.debug('%s disconnected. remainder connected: %d', self.peer, self.factory.num_connections)

        self.factory.remove_connection(self)
        if self.peer_manager:
            self.peer_manager.remove_channel(self) 
Example #12
Source File: tuntap.py    From wifibroadcast with GNU General Public License v3.0 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        abstract.FileDescriptor.connectionLost(self, reason)
        if self.fd is not None:
            os.close(self.fd)
            self.fd = None
        return self.protocol.connectionLost(reason) 
Example #13
Source File: bashplex.py    From epoptes with GNU General Public License v3.0 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """Override Protocol.connectionLost."""
        LOG.w("Connection lost:", self.handle)
        try:
            self.ping_timeout.cancel()
        except Exception:
            pass
        try:
            self.ping_timer.cancel()
        except Exception:
            pass
        if self.handle in exchange.known_clients:
            exchange.client_disconnected(self.handle) 
Example #14
Source File: tcp.py    From pyrdp with GNU General Public License v3.0 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        """
        :param reason: reason for disconnection.
        """
        self.observer.onDisconnection(reason) 
Example #15
Source File: session.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def loseConnection(self):
        self.proto.connectionLost(protocol.connectionDone) 
Example #16
Source File: smtp.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """
        We are no longer connected
        """
        self.setTimeout(None)
        self.mailFile = None 
Example #17
Source File: heartbeat.py    From OpenBazaar-Server with MIT License 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        self.factory.unregister(self) 
Example #18
Source File: ws.py    From OpenBazaar-Server with MIT License 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        self.factory.unregister(self) 
Example #19
Source File: session.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def loseConnection(self):
        self.proto.connectionLost(protocol.connectionDone) 
Example #20
Source File: smtp.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def connectionLost(self, reason=protocol.connectionDone):
        """
        We are no longer connected
        """
        self.setTimeout(None)
        self.mailFile = None 
Example #21
Source File: endpoints.py    From afkak with Apache License 2.0 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        self.disconnected = reason
        self._log.debug("Server connection lost: {reason}", reason=reason) 
Example #22
Source File: _protocol.py    From afkak with Apache License 2.0 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        """
        Mark the protocol as failed and fail all pending operations.
        """
        self._failed = reason
        pending, self._pending = self._pending, None
        for d in pending.values():
            d.errback(reason) 
Example #23
Source File: _protocol.py    From afkak with Apache License 2.0 5 votes vote down vote up
def connectionLost(self, reason=connectionDone):
        self.factory._connectionLost(reason)
        self.factory = None