timeout on reading post body?

10 views
Skip to first unread message

Alec Flett

unread,
Nov 4, 2009, 5:34:47 PM11/4/09
to mod...@googlegroups.com
This doesn't seem to be covered by the WSGI spec, but is there a
standard way to set timeouts reading the post body from wsgi.input? I
see a few settings in the ConfigurationDirectives page which seem
relevant
(inactivity-timeout, etc) but none that quite do what I'm hoping for.
I'm mostly concerned for a service we have where you can upload
images, and we'd like to avoid tying up a wsgi daemon if there's a
slow client - we'd rather just bail on the client.

Is it reasonable to call settimeout() on the file-like object, if it
has such a method?

Alec

Graham Dumpleton

unread,
Nov 4, 2009, 5:40:51 PM11/4/09
to mod...@googlegroups.com
2009/11/5 Alec Flett <al...@metaweb.com>:

> This doesn't seem to be covered by the WSGI spec, but is there a
> standard way to set timeouts reading the post body from wsgi.input?

No.

> I see a few settings in the ConfigurationDirectives page which seem
> relevant
> (inactivity-timeout, etc) but none that quite do what I'm hoping for.
> I'm mostly concerned for a service we have where you can upload
> images, and we'd like to avoid tying up a wsgi daemon if there's a
> slow client - we'd rather just bail on the client.
>
> Is it reasonable to call settimeout() on the file-like object, if it
> has such a method?

No as it isn't a direct wrapper around a socket, but to an internal C
API that maps into Apache input system.

What I would suggest is that you place nginx proxy in front of
Apache/mod_wsgi. This will help as nginx, unless input content size is
over a quite sizeable value, will buffer request content before
proxying it on to the back end server. This has the effective of
isolating Apache/mod_wsgi from slow clients by only passing on a
request when data is all available for Apache/mod_wsgi to respond to
it.

Using nginx like this is a common practice albeit that most may not
understand that this is one of the favourable outcomes from using that
architecture.

Graham

Reply all
Reply to author
Forward
0 new messages