[Twisted-Python] POP3 improvements

screwtape at froup.com screwtape at froup.com
Tue Dec 31 02:08:22 EST 2002


On Tue, Dec 31, 2002 at 05:40:43PM +1100, Andrew Bennetts wrote:
> On Tue, Dec 31, 2002 at 01:24:40AM -0500, Christopher Armstrong wrote:
> > 
> > Euughhh.. that sounds really horrible at first glance. Are there any
> > cases you can think of that actually make use of passing in different
> > Protocol classes? Also, how much less flexible would it be to simply
> > set the protocols as attributes on the FTPClient if you want to
> > override?  (similar to Factory.protocol). The FTPClient would then just use
> > 'self.whateverProtocol'. This agrees much more with what a lot of
> > Twisted already does, I think.
> 
> I do need to use different protocols, or at least I did at a previous job...
> I had a program that downloaded TIFF files and text files.  TIFF files
> needed to be written to disk and processed, text files were written to disk
> for posterity, but were processed as they came in.  

IIRC, the TIFF files in question were very, very large, while the text
files were quite small. TIFF files you'd want to spool to disk as
quickly as possible, but text files you could build them up in a
buffer as they came in.

I imagine the HTTP client would face similar issues - how does it go
downloading large files?

> Also, an FTPClient can have multiple commands queued (It seems reasonable to
> be able to do f.cd('foo/bar'); f.retr('file1'); f.retr('file2')), so an
> instance attribute isn't a sane option.
> 
> Any other ideas, though?  I would like to make it cleaner.

I think it would be nice if Twisted had a DownloadingFile interface or
something - make a new DownloadingFile instance, then pass it to FTP's
RETR, HTTP's GET, an IRC DCC transfer, a twisted.conch scp session, or
whatever. Then you can get the DownloadingFile instance to trigger
deferreds when it's complete, when it's progress is updated, that sort
of thing. It would make it easy to generate stats like download speed,
estimated time, and so forth.

Make a subclass DownloadingTIFFFile that saves the file to disk and
processes it, make a subclass DownloadingTextFile that processes the
file as it comes in, then saves it to disk.

Screwtape,
...yes, another crazy idea I don't particulary want to implement
myself. :)

-- 
 ___________ ____________________________
| Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _  _   _
|
| "The cruel angel's thesis bleeds" 
|




More information about the Twisted-Python mailing list