[Twisted-Python] FTPClient - aborting transfers
matt at bennett.name
Tue Sep 1 18:51:21 EDT 2009
I've got an FTPClient implementation very similar to the one at ,
and I've added the ability to retrieve a file from the server with the
Protocol subclass that writes received data to a local file.
def __init__(self, filename):
self.file = open(filename, 'wb')
def dataReceived(self, data):
receiver = FileReceiver(local_path)
d = ftpClient.retrieveFile(remote_path,receiver)
I want to be able to abort the transfers if they've not completed
after a specific period of time. When the timeout is triggered, I call
ftpClient.transport.loseConnection() which seems to stop the dL on
line 109 of  from firing, but the data transfer continues until
completion. This is true for both storing and retrieving files.
In the storing case, I thought that
twisted.protocols.basic.FileSender's stopProducing method might help,
but all it seems to do is trigger the errback for anyone waiting for a
response - the actual data transfer continues.
How do I abort the transfer and clear the wire when the timeout fires?
More information about the Twisted-Python