[Twisted-Python] Submitted for your consideration

Andrew Bennetts andrew-twisted at puzzling.org
Wed Jun 11 06:27:52 EDT 2003


On Wed, Jun 11, 2003 at 05:52:16AM -0400, Jp Calderone wrote:
>   Attached is a patch to add timeout support to t.web (via a minor
> HTTPChannel change).
> 
>   The performance impact should be light, though it does impose an extra
> function call per received line.  If this is found to unacceptable, I do not
> thing it would be unreasonable to change the "__lastReceived" attribute's
> name, document it as public, and require the update be made inline.

[I've already made this point on IRC, but anyway...]

It also will timeout clients if a request takes a long time to run.  Think
streaming web pages, e.g. LivePage, or a streaming log from a *very* slow
buildbot build.  This patch should use .setTimeout(None) to disable timeouts
while a request is being processed (and then of course re-enable timeouts
once all outstanding requests have been serviced).  I don't like the idea of
disconnecting a client simply because the server is taking a long time to
serve the request, or because a client has a slow link.

I realise the default timeout is 12 hours, but:
    - I can imagine cases where HTTP connections last longer than 12 hours
      without receiving traffic from the client, e.g. streaming HTTP, where
      the client sends nothing, but the server keeps streaming buildbot
      results/javascript events/music, or simply a very long running request
      (i.e. because of an unusually massive DB query, or something).  You'd
      *really* be annoyed if your query took 13 hours, only to discover
      after 12 hours Twisted Web arbitrarily decided your connection was
      idle and killed it.  
    - Another scenario: A dial-up user downloading an ISO of their favorite
      Linux distro.  This is a legitimate request, and shouldn't be
      arbitrarily cut-off halfway.  If a client wants to download 600Mb at
      5kB/s, Twisted Web should let them.
    - It should still work correctly if the default is changed.  Someone
      might be paranoid, and set the timeout down to, say, 5 minutes.  This
      shouldn't cause adverse affects (beyond killing connections that have
      been idle that long).

-Andrew.





More information about the Twisted-Python mailing list