On Wed, Apr 25, 2012 at 11:24 AM, Jim Fulton <
j...@zope.com> wrote:
> On Wed, Apr 25, 2012 at 9:41 AM, Denis Bilenko <
denis....@gmail.com> wrote:
>> On Wed, Apr 25, 2012 at 5:35 PM, Jim Fulton <
j...@zope.com> wrote:
>>> Is there any way to make gevent.pywsgi.WSGIServer time out requests
>>> after long periods of client inactivity?
>>
>> Perhaps using socket's timeout would work for you?
...
>> Let me know if that works for you.
>
> It works great for output. Â
Well, with one relatively minor gripe. For response/output timeouts,
I get output like:
Traceback (most recent call last):
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/pywsgi.py",
line 447, in handle_one_response
self.run_application()
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/pywsgi.py",
line 434, in run_application
self.process_result()
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/pywsgi.py",
line 425, in process_result
self.write(data)
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/pywsgi.py",
line 378, in write
self.socket.sendall(msg)
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/socket.py",
line 474, in sendall
data_sent += self.send(_get_memory(data, data_sent), flags,
timeout=timeleft)
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/socket.py",
line 446, in send
self._wait(self._write_event)
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/socket.py",
line 289, in _wait
self.hub.wait(watcher)
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/hub.py",
line 384, in wait
result = self.switch()
File "/home/jim/.buildout/eggs/gevent-1.0b2-py2.6-linux-x86_64.egg/gevent/hub.py",
line 373, in switch
return greenlet.switch(self)
timeout: timed out
{'GATEWAY_INTERFACE': 'CGI/1.1',
'PATH_INFO': '/gen.html',
'QUERY_STRING': 'size=9951660',
'REMOTE_ADDR': '127.0.0.1',
'REMOTE_PORT': '42062',
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': '',
'SERVER_NAME': 'localhost',
'SERVER_PORT': '51660',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SOFTWARE': 'gevent/1.0 Python/2.6',
'webob._parsed_query_vars': (GET([(u'size', u'9951660')]), 'size=9951660'),
'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7f8ba31321e0>,
'wsgi.input': <gevent.pywsgi.Input object at 0x1ccb7d0>,
'wsgi.multiprocess': False,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)} failed with timeout
127.0.0.1 - - [2012-04-25 11:45:42] "GET /gen.html?size=9951660
HTTP/1.0" socket 204145 10.169218
The traceback and environment listing isn't really helpful. I'd
rather it not be output in this case.
In the access-log line, "socket" isn't a valid status code, although I
don't see what a valid status code would be in this case. If the
server timed out waiting for input, then "408 Request Timeout" would
fit. It's odd that HTTP doesn't provide a code for timing out on
output. Perhaps 408 should apply there too. I definately think it
should be a 4xx status rather than a 5xx.
BTW, I'm using 1.0b2.