diff --git a/gunicorn/workers/gtornado.py b/gunicorn/workers/gtornado.py index 1d98c703..a419a1a0 100644 --- a/gunicorn/workers/gtornado.py +++ b/gunicorn/workers/gtornado.py @@ -9,6 +9,7 @@ import sys import tornado.web from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop, PeriodicCallback +from tornado.wsgi import WSGIContainer from gunicorn.workers.base import Worker @@ -46,6 +47,11 @@ class TornadoWorker(Worker): self.ioloop = IOLoop.instance() PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start() + # Assume the app is a WSGI callable if its not an + # instance of tornardo.web.Application + if not isinstance(self.app, tornado.web.Application): + self.app = WSGIContainer(self.app) + server = HTTPServer(self.app, io_loop=self.ioloop) server._socket = self.socket server.start(num_processes=1)