[Twisted-Python] ftpclient connection lost callback

Peter Ryan peter at peterryan.net
Thu Sep 5 11:49:57 MDT 2013


I am writing a simple ftp client which I am trying to dispose of. Right now
I send a quit command:

(the ftp_client reference is a FTPClient built with a ClientCreator)

deferred = ftp_client.quit()

And I register a callback:

def quitSent(response):
   print "quit acknowledged...connected?", ftp_client.transport.connected

deferred.addCallback(quitSent)

If I invoke the above the connection is printed as connected.

However if I schedule a callback to check the status later:

def status():
   print "quit acknowledged...connected?", ftp_client.transport.connected

reactor.callLater(1, self.status)

If I schedule a callback for a second later the transport is not connected.
I've searched quite a bit but I cannot determine a way to register a
callback for when the TCP transport is actually disconnected. Can anyone
offer some insight? I'd like to know explicitly when the client is closed.

Thanks,

Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20130905/2e1a483b/attachment-0001.html>


More information about the Twisted-Python mailing list