[Twisted-web] Partial HTTP downloads using twisted.web.client.Agent

Carlos Valiente superdupont at gmail.com
Mon Jul 19 11:54:55 EDT 2010

Hi! I need to download a fragment of a file using HTTP. The file is
stored in several hosts, and I need to handle the case where one or
several hosts are down, or do not have a copy of the file, or the
connection fails for any other reason.

Inspired by the Twisted client tutorial
I've written a function called ``download()``
(http://gist.github.com/481575) which iterates through a list of URLs.
I find the resulting code a bit too long, however -- in particular the
need for the ``FileWriter`` class.

Have I overlooked some Twisted helper code, or some Twisted coding
idiom, that could simplify the example above? Can you guys think of
any way to improve that code fragment?

Thanks a lot,


More information about the Twisted-web mailing list