server icon indicating copy to clipboard operation
server copied to clipboard

Introduce gevent request timeout

Open varmar05 opened this issue 4 months ago • 0 comments

Currently we do not have any bounds in case we run server with gevent worker type. In case client gave up on connection server still might be processing request. Also if request is greenlet safe (as it should be!) it can take long time to finish since it yields to gevent hub and standard gunicorn timeout is not applied here.

This PR introduces custom timeout via middleware to cut the request early enough in case of gevent. There are two new related variables GEVENT_WORKER and GEVENT_REQUEST_TIMEOUT.

Logs from a dummy test

[ERROR] [23194] Gevent worker: Request /ping timed out
[ACCESS] - GET /ping  HTTP/1.1 502 11 - "Mozilla/5.0 (X11; Linux x86_64) ..." 1003113 <23194>

varmar05 avatar Oct 29 '24 09:10 varmar05