mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
parent
4b1cbe6a37
commit
9ec27c1ef7
@ -68,20 +68,31 @@ class TornadoWorker(Worker):
|
|||||||
# will help gunicorn shutdown the worker if max_requests
|
# will help gunicorn shutdown the worker if max_requests
|
||||||
# is exceeded.
|
# is exceeded.
|
||||||
httpserver = sys.modules["tornado.httpserver"]
|
httpserver = sys.modules["tornado.httpserver"]
|
||||||
old_connection_finish = httpserver.HTTPConnection.finish
|
if hasattr(httpserver, 'HTTPConnection'):
|
||||||
|
old_connection_finish = httpserver.HTTPConnection.finish
|
||||||
|
|
||||||
def finish(other):
|
def finish(other):
|
||||||
self.handle_request()
|
self.handle_request()
|
||||||
old_connection_finish(other)
|
old_connection_finish(other)
|
||||||
httpserver.HTTPConnection.finish = finish
|
httpserver.HTTPConnection.finish = finish
|
||||||
sys.modules["tornado.httpserver"] = httpserver
|
sys.modules["tornado.httpserver"] = httpserver
|
||||||
|
|
||||||
|
server_class = tornado.httpserver.HTTPServer
|
||||||
|
else:
|
||||||
|
|
||||||
|
class _HTTPServer(tornado.httpserver.HTTPServer):
|
||||||
|
|
||||||
|
def on_close(instance, server_conn):
|
||||||
|
self.handle_request()
|
||||||
|
super(_HTTPServer, instance).on_close(server_conn)
|
||||||
|
|
||||||
|
server_class = _HTTPServer
|
||||||
|
|
||||||
if self.cfg.is_ssl:
|
if self.cfg.is_ssl:
|
||||||
server = tornado.httpserver.HTTPServer(app, io_loop=self.ioloop,
|
server = server_class(app, io_loop=self.ioloop,
|
||||||
ssl_options=self.cfg.ssl_options)
|
ssl_options=self.cfg.ssl_options)
|
||||||
else:
|
else:
|
||||||
server = tornado.httpserver.HTTPServer(app,
|
server = server_class(app, io_loop=self.ioloop)
|
||||||
io_loop=self.ioloop)
|
|
||||||
|
|
||||||
self.server = server
|
self.server = server
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user