mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
patch RequestHandler so people know that they use tornado with gunicorn.
This commit is contained in:
parent
e9eed6b6e9
commit
80e0acf9db
@ -4,14 +4,35 @@
|
|||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from tornado.httpserver import HTTPServer
|
from tornado.httpserver import HTTPServer
|
||||||
from tornado.ioloop import IOLoop, PeriodicCallback
|
from tornado.ioloop import IOLoop, PeriodicCallback
|
||||||
|
|
||||||
|
|
||||||
from gunicorn.workers.base import Worker
|
from gunicorn.workers.base import Worker
|
||||||
|
from gunicorn import __version__ as gversion
|
||||||
|
|
||||||
|
|
||||||
|
def patch_request_handler():
|
||||||
|
web = sys.modules.pop("tornado.web")
|
||||||
|
|
||||||
|
old_clear = web.RequestHandler.clear
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
old_clear(self)
|
||||||
|
self._headers["Server"] += " (Gunicorn/%s)" % gversion
|
||||||
|
|
||||||
|
web.RequestHandler.clear = clear
|
||||||
|
sys.modules["tornado.web"] = web
|
||||||
|
|
||||||
|
|
||||||
class TornadoWorker(Worker):
|
class TornadoWorker(Worker):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setup(cls):
|
||||||
|
patch_request_handler()
|
||||||
|
|
||||||
def watchdog(self):
|
def watchdog(self):
|
||||||
self.notify()
|
self.notify()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user