2019-07-02 06:32:26 +00:00
|
|
|
from gevent.pywsgi import WSGIServer, WSGIHandler
|
|
|
|
from gevent import Timeout
|
2020-08-26 08:25:43 +00:00
|
|
|
|
|
|
|
|
2019-07-02 06:32:26 +00:00
|
|
|
class FDSafeHandler(WSGIHandler):
|
|
|
|
'''Our WSGI handler. Doesn't do much non-default except timeouts'''
|
|
|
|
def handle(self):
|
|
|
|
self.timeout = Timeout(120, Exception)
|
|
|
|
self.timeout.start()
|
|
|
|
try:
|
|
|
|
WSGIHandler.handle(self)
|
2019-08-06 21:19:26 +00:00
|
|
|
except Timeout as ex:
|
2019-08-05 16:30:19 +00:00
|
|
|
if ex is self.timeout:
|
|
|
|
pass
|
2020-08-26 08:25:43 +00:00
|
|
|
else:
|
2019-08-05 16:30:19 +00:00
|
|
|
raise
|