From 80e0acf9db19d2192be571ada332d884a5d70ee7 Mon Sep 17 00:00:00 2001 From: benoitc Date: Thu, 22 Apr 2010 18:45:22 +0200 Subject: [PATCH] patch RequestHandler so people know that they use tornado with gunicorn. --- gunicorn/workers/gtornado.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gunicorn/workers/gtornado.py b/gunicorn/workers/gtornado.py index 9f7ae4b7..7df9672c 100644 --- a/gunicorn/workers/gtornado.py +++ b/gunicorn/workers/gtornado.py @@ -4,14 +4,35 @@ # See the NOTICE for more information. import os +import sys from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop, PeriodicCallback + 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): + @classmethod + def setup(cls): + patch_request_handler() + def watchdog(self): self.notify()