Python twisted.internet.reactor.disconnectAll() Examples
The following are 6
code examples of twisted.internet.reactor.disconnectAll().
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.reactor
, or try the search function
.
Example #1
Source File: test_tcp.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_directConnectionLostCall(self): """ If C{connectionLost} is called directly on a port object, it succeeds (and doesn't expect the presence of a C{deferred} attribute). C{connectionLost} is called by L{reactor.disconnectAll} at shutdown. """ serverFactory = MyServerFactory() port = reactor.listenTCP(0, serverFactory, interface="127.0.0.1") portNumber = port.getHost().port port.connectionLost(None) client = MyClientFactory() serverFactory.protocolConnectionMade = defer.Deferred() client.protocolConnectionMade = defer.Deferred() reactor.connectTCP("127.0.0.1", portNumber, client) def check(ign): client.reason.trap(error.ConnectionRefusedError) return client.failDeferred.addCallback(check)
Example #2
Source File: test_tcp.py From learn_python3_spider with MIT License | 6 votes |
def test_directConnectionLostCall(self): """ If C{connectionLost} is called directly on a port object, it succeeds (and doesn't expect the presence of a C{deferred} attribute). C{connectionLost} is called by L{reactor.disconnectAll} at shutdown. """ serverFactory = MyServerFactory() port = reactor.listenTCP(0, serverFactory, interface="127.0.0.1") portNumber = port.getHost().port port.connectionLost(None) client = MyClientFactory() serverFactory.protocolConnectionMade = defer.Deferred() client.protocolConnectionMade = defer.Deferred() reactor.connectTCP("127.0.0.1", portNumber, client) def check(ign): client.reason.trap(error.ConnectionRefusedError) return client.failDeferred.addCallback(check)
Example #3
Source File: test_tcp.py From python-for-android with Apache License 2.0 | 6 votes |
def test_directConnectionLostCall(self): """ If C{connectionLost} is called directly on a port object, it succeeds (and doesn't expect the presence of a C{deferred} attribute). C{connectionLost} is called by L{reactor.disconnectAll} at shutdown. """ serverFactory = MyServerFactory() port = reactor.listenTCP(0, serverFactory, interface="127.0.0.1") portNumber = port.getHost().port port.connectionLost(None) client = MyClientFactory() serverFactory.protocolConnectionMade = defer.Deferred() client.protocolConnectionMade = defer.Deferred() reactor.connectTCP("127.0.0.1", portNumber, client) def check(ign): client.reason.trap(error.ConnectionRefusedError) return client.failDeferred.addCallback(check)
Example #4
Source File: test_tcp.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def test_exceptInConnectionLostCall(self): """ If C{connectionLost} is called directory on a port object and that the server factory raises an exception in C{stopFactory}, the exception is passed through to the caller. C{connectionLost} is called by L{reactor.disconnectAll} at shutdown. """ serverFactory = MyServerFactory() def raiseException(): raise RuntimeError("An error") serverFactory.stopFactory = raiseException port = reactor.listenTCP(0, serverFactory, interface="127.0.0.1") self.assertRaises(RuntimeError, port.connectionLost, None)
Example #5
Source File: test_tcp.py From learn_python3_spider with MIT License | 5 votes |
def test_exceptInConnectionLostCall(self): """ If C{connectionLost} is called directory on a port object and that the server factory raises an exception in C{stopFactory}, the exception is passed through to the caller. C{connectionLost} is called by L{reactor.disconnectAll} at shutdown. """ serverFactory = MyServerFactory() def raiseException(): raise RuntimeError("An error") serverFactory.stopFactory = raiseException port = reactor.listenTCP(0, serverFactory, interface="127.0.0.1") self.assertRaises(RuntimeError, port.connectionLost, None)
Example #6
Source File: test_tcp.py From python-for-android with Apache License 2.0 | 5 votes |
def test_exceptInConnectionLostCall(self): """ If C{connectionLost} is called directory on a port object and that the server factory raises an exception in C{stopFactory}, the exception is passed through to the caller. C{connectionLost} is called by L{reactor.disconnectAll} at shutdown. """ serverFactory = MyServerFactory() def raiseException(): raise RuntimeError("An error") serverFactory.stopFactory = raiseException port = reactor.listenTCP(0, serverFactory, interface="127.0.0.1") self.assertRaises(RuntimeError, port.connectionLost, None)