[Twisted-Python] deferreds and hung connections

Lenny G Arbage alengarbage at yahoo.com
Wed Mar 9 14:17:58 EST 2005

--- Jp Calderone <exarkun at divmod.com> wrote:
>   As was recently mentioned on the list, timeout
> support needs 
> to be part of the result-generating API.  Luckily,
> in the case 
> of getPage, it is, as demonstrated by this manhole
> session:
>     >>> from twisted.web import client
>     >>> client.getPage('http://google.com',
> timeout=0.001)
>     <Deferred #0>
>     Deferred #0 failed: 'Getting http://google.com
> took longer than 0.001
>     seconds.'
>     >>> 

  Thanks for the pointer, Jp.  I just stumbled on some
of the threads on the mailing list stretching back to
as far as 2002 about whether being able to cancel
Deferreds was a good idea or not.

  So the above solution works.  Where do I catch, or
otherwise react to, the error printed above?  When the
Deferred times out, is there a way to inject another
callback in there ("timeoutcallback"?) so that I can
do some processing on timeout?

  It looks like I could override HTTPClientFactory's
timeout() method if I had a handle to it, but
getPage() doesn't give me access.  Am I barking up the
wrong tree?


Celebrate Yahoo!'s 10th Birthday! 
Yahoo! Netrospective: 100 Moments of the Web 

More information about the Twisted-Python mailing list