[Twisted-Python] Re: [Twisted-commits] r16103 - Make loopbackTCP and loopbackUNIX return Deferreds
On Tue, 28 Feb 2006 05:37:54 -0700, Jonathan Lange <jml@wolfwood.twistedmatrix.com> wrote:
Author: jml Date: Tue Feb 28 05:37:52 2006 New Revision: 16103
Modified: branches/deprecated-trial-1509/twisted/mail/test/test_imap.py branches/deprecated-trial-1509/twisted/mail/test/test_pop3.py branches/deprecated-trial-1509/twisted/mail/test/test_pop3client.py branches/deprecated-trial-1509/twisted/mail/test/test_smtp.py branches/deprecated-trial-1509/twisted/protocols/loopback.py branches/deprecated-trial-1509/twisted/test/test_loopback.py branches/deprecated-trial-1509/twisted/test/test_tpfile.py Log: Make loopbackTCP and loopbackUNIX return Deferreds
Modified: branches/deprecated-trial-1509/twisted/protocols/loopback.py ============================================================================== --- branches/deprecated-trial-1509/twisted/protocols/loopback.py (original) +++ branches/deprecated-trial-1509/twisted/protocols/loopback.py Tue Feb 28 05:37:52 2006 @@ -122,14 +123,9 @@ clientF.noisy = noisy reactor.connectTCP('127.0.0.1', serverPort.getHost().port, clientF)
- # this needs to wait until: - # A: the client has disconnected - # B: the server has noticed, and its own socket has disconnected - # C: the listening socket has been shut down - spinUntil(lambda :clientF.disconnected) # A - spinUntil(lambda :not server.transport.connected) # B - serverPort.stopListening() - spinUntil(lambda :not serverPort.connected) # C + d = clientF.deferred + d.addCallback(lambda x : defer.maybeDeferred(serverPort.stopListening)) + return d
This now has a race, where the Deferred may fire before the server protocol is notified that the connection has been lost. Jean-Paul
On 3/1/06, Jean-Paul Calderone <exarkun@divmod.com> wrote:
On Tue, 28 Feb 2006 05:37:54 -0700, Jonathan Lange <jml@wolfwood.twistedmatrix.com> wrote:
Author: jml Date: Tue Feb 28 05:37:52 2006 New Revision: 16103
Modified: branches/deprecated-trial-1509/twisted/mail/test/test_imap.py branches/deprecated-trial-1509/twisted/mail/test/test_pop3.py branches/deprecated-trial-1509/twisted/mail/test/test_pop3client.py branches/deprecated-trial-1509/twisted/mail/test/test_smtp.py branches/deprecated-trial-1509/twisted/protocols/loopback.py branches/deprecated-trial-1509/twisted/test/test_loopback.py branches/deprecated-trial-1509/twisted/test/test_tpfile.py Log: Make loopbackTCP and loopbackUNIX return Deferreds
Modified: branches/deprecated-trial-1509/twisted/protocols/loopback.py ============================================================================== --- branches/deprecated-trial-1509/twisted/protocols/loopback.py (original) +++ branches/deprecated-trial-1509/twisted/protocols/loopback.py Tue Feb 28 05:37:52 2006 @@ -122,14 +123,9 @@ clientF.noisy = noisy reactor.connectTCP('127.0.0.1', serverPort.getHost().port, clientF)
- # this needs to wait until: - # A: the client has disconnected - # B: the server has noticed, and its own socket has disconnected - # C: the listening socket has been shut down - spinUntil(lambda :clientF.disconnected) # A - spinUntil(lambda :not server.transport.connected) # B - serverPort.stopListening() - spinUntil(lambda :not serverPort.connected) # C + d = clientF.deferred + d.addCallback(lambda x : defer.maybeDeferred(serverPort.stopListening)) + return d
This now has a race, where the Deferred may fire before the server protocol is notified that the connection has been lost.
Awesome, I wondered what that other thing was for. How do I get a Deferred to fire when a transport is disconnected? jml
On Wed, 1 Mar 2006 07:42:05 +1100, Jonathan Lange <jml@mumak.net> wrote:
On 3/1/06, Jean-Paul Calderone <exarkun@divmod.com> wrote: [snip]
This now has a race, where the Deferred may fire before the server protocol is notified that the connection has been lost.
Awesome, I wondered what that other thing was for.
How do I get a Deferred to fire when a transport is disconnected?
Probably with a protocol wrapper. Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
Jonathan Lange