Hi, Glyph Lefkowitz wrote:
Oisin Mulvihill wrote:
I confess I really don't know how to handle the two deferred object that get returned by storeFile. I just add callback/ errorback for each, this could be the problem.
If you want to wait for both, use twisted.internet.defer.DeferredList.
Why are there two deferred objects returned by storeFile? The documentation says: storeFile (self ,path ): Store a file at the given path. This method issues the 'STOR' FTP command. Returns: A tuple of two Deferreds: * Deferred IFinishableConsumer . You must call the finish method on the IFinishableConsumer when the file is completely transferred. * Deferred list of control-connection responses. This really doesn't help me much. I get the impression that storeFile isn't sending the contents of file, because its waiting for me to stream the file contents somehow. Maybe via IFinishableConsumer? In my current program, using ftplib, I do the following to upload a file: : ftp.storbinary('STOR %s' % (filename), fp) : This has the filename and a file descriptor passed to it. Is something like this needed with storeFile? Please can someone give me an answer to this, as looking at the code for twisted.protocols.ftp isn't helping much either. This function seems to be a mystery to me and I want to understand how to use it properly. Thanks, om
Can anyone enlighten me as to what I'm doing wrong. I would really like to use proper async behavior for doing the uploads, instead of using threads + ftplib.
The FTP implementation in Twisted is sub-optimal (although that's mostly the server). If you don't get any satisfactory responses I recommend assigning a bug to spiv in the tracker :).
-- Oisin Mulvihill Engines Of Creation Email: oisin@enginesofcreation.ie Work: +353 1 6791602 Mobile: +353 868191540