We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
tornado 5.0+ not compatible with gunicorn
gunicorn version: 19.7.1
tornado: 5.0

failed with:

```
$ ./bin/gunicorn -w 1 -t 300 -k tornado web:app -b 0.0.0.0:9003
[2018-03-20 14:17:29 +0000] [28600] [INFO] Starting gunicorn 19.7.1
[2018-03-20 14:17:29 +0000] [28600] [INFO] Listening at: http://0.0.0.0:9003 (28600)
[2018-03-20 14:17:29 +0000] [28600] [INFO] Using worker: tornado
[2018-03-20 14:17:29 +0000] [28605] [INFO] Booting worker with pid: 28605
[2018-03-20 14:17:29 +0000] [28605] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/arbiter.py", line 578, in spawn_worker
    worker.init_process()
  File "/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/base.py", line 131, in init_process
    self.run()
  File "/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/gtornado.py", line 70, in run
    PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()
TypeError: __init__() got an unexpected keyword argument 'io_loop'
[2018-03-20 14:17:29 +0000] [28605] [INFO] Worker exiting (pid: 28605)
[2018-03-20 14:17:29 +0000] [28608] [INFO] Booting worker with pid: 28608
[2018-03-20 14:17:29 +0000] [28608] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/arbiter.py", line 578, in spawn_worker
    worker.init_process()
  File "/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/base.py", line 131, in init_process
    self.run()
  File "/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/gtornado.py", line 70, in run
    PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()
TypeError: __init__() got an unexpected keyword argument 'io_loop'
```
according to the release note of Tornado 5.0:

```
io_loop arguments to many Tornado functions have been removed. Use IOLoop.current() instead of passing IOLoop objects explicitly.
```
http://www.tornadoweb.org/en/stable/releases/v5.0.0.html#backwards-compatibility-notes

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gunicorn/workers/gtornado.py`
Content:
```
1 # -*- coding: utf-8 -
2 #
3 # This file is part of gunicorn released under the MIT license.
4 # See the NOTICE for more information.
5 
6 import copy
7 import os
8 import sys
9 
10 try:
11     import tornado.web
12 except ImportError:
13     raise RuntimeError("You need tornado installed to use this worker.")
14 import tornado.httpserver
15 from tornado.ioloop import IOLoop, PeriodicCallback
16 from tornado.wsgi import WSGIContainer
17 from gunicorn.workers.base import Worker
18 from gunicorn import __version__ as gversion
19 
20 
21 class TornadoWorker(Worker):
22 
23     @classmethod
24     def setup(cls):
25         web = sys.modules.pop("tornado.web")
26         old_clear = web.RequestHandler.clear
27 
28         def clear(self):
29             old_clear(self)
30             if "Gunicorn" not in self._headers["Server"]:
31                 self._headers["Server"] += " (Gunicorn/%s)" % gversion
32         web.RequestHandler.clear = clear
33         sys.modules["tornado.web"] = web
34 
35     def handle_exit(self, sig, frame):
36         if self.alive:
37             super(TornadoWorker, self).handle_exit(sig, frame)
38 
39     def handle_request(self):
40         self.nr += 1
41         if self.alive and self.nr >= self.max_requests:
42             self.log.info("Autorestarting worker after current request.")
43             self.alive = False
44 
45     def watchdog(self):
46         if self.alive:
47             self.notify()
48 
49         if self.ppid != os.getppid():
50             self.log.info("Parent changed, shutting down: %s", self)
51             self.alive = False
52 
53     def heartbeat(self):
54         if not self.alive:
55             if self.server_alive:
56                 if hasattr(self, 'server'):
57                     try:
58                         self.server.stop()
59                     except Exception:
60                         pass
61                 self.server_alive = False
62             else:
63                 if not self.ioloop._callbacks:
64                     self.ioloop.stop()
65 
66     def run(self):
67         self.ioloop = IOLoop.instance()
68         self.alive = True
69         self.server_alive = False
70         PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()
71         PeriodicCallback(self.heartbeat, 1000, io_loop=self.ioloop).start()
72 
73         # Assume the app is a WSGI callable if its not an
74         # instance of tornado.web.Application or is an
75         # instance of tornado.wsgi.WSGIApplication
76         app = self.wsgi
77         if not isinstance(app, tornado.web.Application) or \
78            isinstance(app, tornado.wsgi.WSGIApplication):
79             app = WSGIContainer(app)
80 
81         # Monkey-patching HTTPConnection.finish to count the
82         # number of requests being handled by Tornado. This
83         # will help gunicorn shutdown the worker if max_requests
84         # is exceeded.
85         httpserver = sys.modules["tornado.httpserver"]
86         if hasattr(httpserver, 'HTTPConnection'):
87             old_connection_finish = httpserver.HTTPConnection.finish
88 
89             def finish(other):
90                 self.handle_request()
91                 old_connection_finish(other)
92             httpserver.HTTPConnection.finish = finish
93             sys.modules["tornado.httpserver"] = httpserver
94 
95             server_class = tornado.httpserver.HTTPServer
96         else:
97 
98             class _HTTPServer(tornado.httpserver.HTTPServer):
99 
100                 def on_close(instance, server_conn):
101                     self.handle_request()
102                     super(_HTTPServer, instance).on_close(server_conn)
103 
104             server_class = _HTTPServer
105 
106         if self.cfg.is_ssl:
107             _ssl_opt = copy.deepcopy(self.cfg.ssl_options)
108             # tornado refuses initialization if ssl_options contains following
109             # options
110             del _ssl_opt["do_handshake_on_connect"]
111             del _ssl_opt["suppress_ragged_eofs"]
112             server = server_class(app, io_loop=self.ioloop,
113                                   ssl_options=_ssl_opt)
114         else:
115             server = server_class(app, io_loop=self.ioloop)
116 
117         self.server = server
118         self.server_alive = True
119 
120         for s in self.sockets:
121             s.setblocking(0)
122             if hasattr(server, "add_socket"):  # tornado > 2.0
123                 server.add_socket(s)
124             elif hasattr(server, "_sockets"):  # tornado 2.0
125                 server._sockets[s.fileno()] = s
126 
127         server.no_keep_alive = self.cfg.keepalive <= 0
128         server.start(num_processes=1)
129 
130         self.ioloop.start()
131
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/gunicorn/workers/gtornado.py b/gunicorn/workers/gtornado.py
--- a/gunicorn/workers/gtornado.py
+++ b/gunicorn/workers/gtornado.py
@@ -8,9 +8,10 @@
 import sys
 
 try:
-    import tornado.web
+    import tornado
 except ImportError:
     raise RuntimeError("You need tornado installed to use this worker.")
+import tornado.web
 import tornado.httpserver
 from tornado.ioloop import IOLoop, PeriodicCallback
 from tornado.wsgi import WSGIContainer
@@ -18,6 +19,11 @@
 from gunicorn import __version__ as gversion
 
 
+# `io_loop` arguments to many Tornado functions have been removed in Tornado 5.0
+# <http://www.tornadoweb.org/en/stable/releases/v5.0.0.html#backwards-compatibility-notes>
+IOLOOP_PARAMETER_REMOVED = tornado.version_info >= (5, 0, 0)
+
+
 class TornadoWorker(Worker):
 
     @classmethod
@@ -67,8 +73,12 @@
         self.ioloop = IOLoop.instance()
         self.alive = True
         self.server_alive = False
-        PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()
-        PeriodicCallback(self.heartbeat, 1000, io_loop=self.ioloop).start()
+        if IOLOOP_PARAMETER_REMOVED:
+            PeriodicCallback(self.watchdog, 1000).start()
+            PeriodicCallback(self.heartbeat, 1000).start()
+        else:
+            PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()
+            PeriodicCallback(self.heartbeat, 1000, io_loop=self.ioloop).start()
 
         # Assume the app is a WSGI callable if its not an
         # instance of tornado.web.Application or is an
@@ -109,10 +119,16 @@
             # options
             del _ssl_opt["do_handshake_on_connect"]
             del _ssl_opt["suppress_ragged_eofs"]
-            server = server_class(app, io_loop=self.ioloop,
-                                  ssl_options=_ssl_opt)
+            if IOLOOP_PARAMETER_REMOVED:
+                server = server_class(app, ssl_options=_ssl_opt)
+            else:
+                server = server_class(app, io_loop=self.ioloop,
+                                      ssl_options=_ssl_opt)
         else:
-            server = server_class(app, io_loop=self.ioloop)
+            if IOLOOP_PARAMETER_REMOVED:
+                server = server_class(app)
+            else:
+                server = server_class(app, io_loop=self.ioloop)
 
         self.server = server
         self.server_alive = True

{"golden_diff": "diff --git a/gunicorn/workers/gtornado.py b/gunicorn/workers/gtornado.py\n--- a/gunicorn/workers/gtornado.py\n+++ b/gunicorn/workers/gtornado.py\n@@ -8,9 +8,10 @@\n import sys\n \n try:\n-    import tornado.web\n+    import tornado\n except ImportError:\n     raise RuntimeError(\"You need tornado installed to use this worker.\")\n+import tornado.web\n import tornado.httpserver\n from tornado.ioloop import IOLoop, PeriodicCallback\n from tornado.wsgi import WSGIContainer\n@@ -18,6 +19,11 @@\n from gunicorn import __version__ as gversion\n \n \n+# `io_loop` arguments to many Tornado functions have been removed in Tornado 5.0\n+# <http://www.tornadoweb.org/en/stable/releases/v5.0.0.html#backwards-compatibility-notes>\n+IOLOOP_PARAMETER_REMOVED = tornado.version_info >= (5, 0, 0)\n+\n+\n class TornadoWorker(Worker):\n \n     @classmethod\n@@ -67,8 +73,12 @@\n         self.ioloop = IOLoop.instance()\n         self.alive = True\n         self.server_alive = False\n-        PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()\n-        PeriodicCallback(self.heartbeat, 1000, io_loop=self.ioloop).start()\n+        if IOLOOP_PARAMETER_REMOVED:\n+            PeriodicCallback(self.watchdog, 1000).start()\n+            PeriodicCallback(self.heartbeat, 1000).start()\n+        else:\n+            PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()\n+            PeriodicCallback(self.heartbeat, 1000, io_loop=self.ioloop).start()\n \n         # Assume the app is a WSGI callable if its not an\n         # instance of tornado.web.Application or is an\n@@ -109,10 +119,16 @@\n             # options\n             del _ssl_opt[\"do_handshake_on_connect\"]\n             del _ssl_opt[\"suppress_ragged_eofs\"]\n-            server = server_class(app, io_loop=self.ioloop,\n-                                  ssl_options=_ssl_opt)\n+            if IOLOOP_PARAMETER_REMOVED:\n+                server = server_class(app, ssl_options=_ssl_opt)\n+            else:\n+                server = server_class(app, io_loop=self.ioloop,\n+                                      ssl_options=_ssl_opt)\n         else:\n-            server = server_class(app, io_loop=self.ioloop)\n+            if IOLOOP_PARAMETER_REMOVED:\n+                server = server_class(app)\n+            else:\n+                server = server_class(app, io_loop=self.ioloop)\n \n         self.server = server\n         self.server_alive = True\n", "issue": "tornado 5.0+ not compatible with gunicorn\ngunicorn version: 19.7.1\r\ntornado: 5.0\r\n\r\nfailed with:\r\n\r\n```\r\n$ ./bin/gunicorn -w 1 -t 300 -k tornado web:app -b 0.0.0.0:9003\r\n[2018-03-20 14:17:29 +0000] [28600] [INFO] Starting gunicorn 19.7.1\r\n[2018-03-20 14:17:29 +0000] [28600] [INFO] Listening at: http://0.0.0.0:9003 (28600)\r\n[2018-03-20 14:17:29 +0000] [28600] [INFO] Using worker: tornado\r\n[2018-03-20 14:17:29 +0000] [28605] [INFO] Booting worker with pid: 28605\r\n[2018-03-20 14:17:29 +0000] [28605] [ERROR] Exception in worker process\r\nTraceback (most recent call last):\r\n  File \"/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/arbiter.py\", line 578, in spawn_worker\r\n    worker.init_process()\r\n  File \"/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/base.py\", line 131, in init_process\r\n    self.run()\r\n  File \"/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/gtornado.py\", line 70, in run\r\n    PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()\r\nTypeError: __init__() got an unexpected keyword argument 'io_loop'\r\n[2018-03-20 14:17:29 +0000] [28605] [INFO] Worker exiting (pid: 28605)\r\n[2018-03-20 14:17:29 +0000] [28608] [INFO] Booting worker with pid: 28608\r\n[2018-03-20 14:17:29 +0000] [28608] [ERROR] Exception in worker process\r\nTraceback (most recent call last):\r\n  File \"/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/arbiter.py\", line 578, in spawn_worker\r\n    worker.init_process()\r\n  File \"/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/base.py\", line 131, in init_process\r\n    self.run()\r\n  File \"/data/data/pkgs/nginxgw/nginxgw-45-838b8953/.buildout/eggs/gunicorn-19.7.1-py2.py3-none-any.ovo/gunicorn/workers/gtornado.py\", line 70, in run\r\n    PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()\r\nTypeError: __init__() got an unexpected keyword argument 'io_loop'\r\n```\r\naccording to the release note of Tornado 5.0:\r\n\r\n```\r\nio_loop arguments to many Tornado functions have been removed. Use IOLoop.current() instead of passing IOLoop objects explicitly.\r\n```\r\nhttp://www.tornadoweb.org/en/stable/releases/v5.0.0.html#backwards-compatibility-notes\n", "before_files": [{"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nimport copy\nimport os\nimport sys\n\ntry:\n    import tornado.web\nexcept ImportError:\n    raise RuntimeError(\"You need tornado installed to use this worker.\")\nimport tornado.httpserver\nfrom tornado.ioloop import IOLoop, PeriodicCallback\nfrom tornado.wsgi import WSGIContainer\nfrom gunicorn.workers.base import Worker\nfrom gunicorn import __version__ as gversion\n\n\nclass TornadoWorker(Worker):\n\n    @classmethod\n    def setup(cls):\n        web = sys.modules.pop(\"tornado.web\")\n        old_clear = web.RequestHandler.clear\n\n        def clear(self):\n            old_clear(self)\n            if \"Gunicorn\" not in self._headers[\"Server\"]:\n                self._headers[\"Server\"] += \" (Gunicorn/%s)\" % gversion\n        web.RequestHandler.clear = clear\n        sys.modules[\"tornado.web\"] = web\n\n    def handle_exit(self, sig, frame):\n        if self.alive:\n            super(TornadoWorker, self).handle_exit(sig, frame)\n\n    def handle_request(self):\n        self.nr += 1\n        if self.alive and self.nr >= self.max_requests:\n            self.log.info(\"Autorestarting worker after current request.\")\n            self.alive = False\n\n    def watchdog(self):\n        if self.alive:\n            self.notify()\n\n        if self.ppid != os.getppid():\n            self.log.info(\"Parent changed, shutting down: %s\", self)\n            self.alive = False\n\n    def heartbeat(self):\n        if not self.alive:\n            if self.server_alive:\n                if hasattr(self, 'server'):\n                    try:\n                        self.server.stop()\n                    except Exception:\n                        pass\n                self.server_alive = False\n            else:\n                if not self.ioloop._callbacks:\n                    self.ioloop.stop()\n\n    def run(self):\n        self.ioloop = IOLoop.instance()\n        self.alive = True\n        self.server_alive = False\n        PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()\n        PeriodicCallback(self.heartbeat, 1000, io_loop=self.ioloop).start()\n\n        # Assume the app is a WSGI callable if its not an\n        # instance of tornado.web.Application or is an\n        # instance of tornado.wsgi.WSGIApplication\n        app = self.wsgi\n        if not isinstance(app, tornado.web.Application) or \\\n           isinstance(app, tornado.wsgi.WSGIApplication):\n            app = WSGIContainer(app)\n\n        # Monkey-patching HTTPConnection.finish to count the\n        # number of requests being handled by Tornado. This\n        # will help gunicorn shutdown the worker if max_requests\n        # is exceeded.\n        httpserver = sys.modules[\"tornado.httpserver\"]\n        if hasattr(httpserver, 'HTTPConnection'):\n            old_connection_finish = httpserver.HTTPConnection.finish\n\n            def finish(other):\n                self.handle_request()\n                old_connection_finish(other)\n            httpserver.HTTPConnection.finish = finish\n            sys.modules[\"tornado.httpserver\"] = httpserver\n\n            server_class = tornado.httpserver.HTTPServer\n        else:\n\n            class _HTTPServer(tornado.httpserver.HTTPServer):\n\n                def on_close(instance, server_conn):\n                    self.handle_request()\n                    super(_HTTPServer, instance).on_close(server_conn)\n\n            server_class = _HTTPServer\n\n        if self.cfg.is_ssl:\n            _ssl_opt = copy.deepcopy(self.cfg.ssl_options)\n            # tornado refuses initialization if ssl_options contains following\n            # options\n            del _ssl_opt[\"do_handshake_on_connect\"]\n            del _ssl_opt[\"suppress_ragged_eofs\"]\n            server = server_class(app, io_loop=self.ioloop,\n                                  ssl_options=_ssl_opt)\n        else:\n            server = server_class(app, io_loop=self.ioloop)\n\n        self.server = server\n        self.server_alive = True\n\n        for s in self.sockets:\n            s.setblocking(0)\n            if hasattr(server, \"add_socket\"):  # tornado > 2.0\n                server.add_socket(s)\n            elif hasattr(server, \"_sockets\"):  # tornado 2.0\n                server._sockets[s.fileno()] = s\n\n        server.no_keep_alive = self.cfg.keepalive <= 0\n        server.start(num_processes=1)\n\n        self.ioloop.start()\n", "path": "gunicorn/workers/gtornado.py"}], "after_files": [{"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nimport copy\nimport os\nimport sys\n\ntry:\n    import tornado\nexcept ImportError:\n    raise RuntimeError(\"You need tornado installed to use this worker.\")\nimport tornado.web\nimport tornado.httpserver\nfrom tornado.ioloop import IOLoop, PeriodicCallback\nfrom tornado.wsgi import WSGIContainer\nfrom gunicorn.workers.base import Worker\nfrom gunicorn import __version__ as gversion\n\n\n# `io_loop` arguments to many Tornado functions have been removed in Tornado 5.0\n# <http://www.tornadoweb.org/en/stable/releases/v5.0.0.html#backwards-compatibility-notes>\nIOLOOP_PARAMETER_REMOVED = tornado.version_info >= (5, 0, 0)\n\n\nclass TornadoWorker(Worker):\n\n    @classmethod\n    def setup(cls):\n        web = sys.modules.pop(\"tornado.web\")\n        old_clear = web.RequestHandler.clear\n\n        def clear(self):\n            old_clear(self)\n            if \"Gunicorn\" not in self._headers[\"Server\"]:\n                self._headers[\"Server\"] += \" (Gunicorn/%s)\" % gversion\n        web.RequestHandler.clear = clear\n        sys.modules[\"tornado.web\"] = web\n\n    def handle_exit(self, sig, frame):\n        if self.alive:\n            super(TornadoWorker, self).handle_exit(sig, frame)\n\n    def handle_request(self):\n        self.nr += 1\n        if self.alive and self.nr >= self.max_requests:\n            self.log.info(\"Autorestarting worker after current request.\")\n            self.alive = False\n\n    def watchdog(self):\n        if self.alive:\n            self.notify()\n\n        if self.ppid != os.getppid():\n            self.log.info(\"Parent changed, shutting down: %s\", self)\n            self.alive = False\n\n    def heartbeat(self):\n        if not self.alive:\n            if self.server_alive:\n                if hasattr(self, 'server'):\n                    try:\n                        self.server.stop()\n                    except Exception:\n                        pass\n                self.server_alive = False\n            else:\n                if not self.ioloop._callbacks:\n                    self.ioloop.stop()\n\n    def run(self):\n        self.ioloop = IOLoop.instance()\n        self.alive = True\n        self.server_alive = False\n        if IOLOOP_PARAMETER_REMOVED:\n            PeriodicCallback(self.watchdog, 1000).start()\n            PeriodicCallback(self.heartbeat, 1000).start()\n        else:\n            PeriodicCallback(self.watchdog, 1000, io_loop=self.ioloop).start()\n            PeriodicCallback(self.heartbeat, 1000, io_loop=self.ioloop).start()\n\n        # Assume the app is a WSGI callable if its not an\n        # instance of tornado.web.Application or is an\n        # instance of tornado.wsgi.WSGIApplication\n        app = self.wsgi\n        if not isinstance(app, tornado.web.Application) or \\\n           isinstance(app, tornado.wsgi.WSGIApplication):\n            app = WSGIContainer(app)\n\n        # Monkey-patching HTTPConnection.finish to count the\n        # number of requests being handled by Tornado. This\n        # will help gunicorn shutdown the worker if max_requests\n        # is exceeded.\n        httpserver = sys.modules[\"tornado.httpserver\"]\n        if hasattr(httpserver, 'HTTPConnection'):\n            old_connection_finish = httpserver.HTTPConnection.finish\n\n            def finish(other):\n                self.handle_request()\n                old_connection_finish(other)\n            httpserver.HTTPConnection.finish = finish\n            sys.modules[\"tornado.httpserver\"] = httpserver\n\n            server_class = tornado.httpserver.HTTPServer\n        else:\n\n            class _HTTPServer(tornado.httpserver.HTTPServer):\n\n                def on_close(instance, server_conn):\n                    self.handle_request()\n                    super(_HTTPServer, instance).on_close(server_conn)\n\n            server_class = _HTTPServer\n\n        if self.cfg.is_ssl:\n            _ssl_opt = copy.deepcopy(self.cfg.ssl_options)\n            # tornado refuses initialization if ssl_options contains following\n            # options\n            del _ssl_opt[\"do_handshake_on_connect\"]\n            del _ssl_opt[\"suppress_ragged_eofs\"]\n            if IOLOOP_PARAMETER_REMOVED:\n                server = server_class(app, ssl_options=_ssl_opt)\n            else:\n                server = server_class(app, io_loop=self.ioloop,\n                                      ssl_options=_ssl_opt)\n        else:\n            if IOLOOP_PARAMETER_REMOVED:\n                server = server_class(app)\n            else:\n                server = server_class(app, io_loop=self.ioloop)\n\n        self.server = server\n        self.server_alive = True\n\n        for s in self.sockets:\n            s.setblocking(0)\n            if hasattr(server, \"add_socket\"):  # tornado > 2.0\n                server.add_socket(s)\n            elif hasattr(server, \"_sockets\"):  # tornado 2.0\n                server._sockets[s.fileno()] = s\n\n        server.no_keep_alive = self.cfg.keepalive <= 0\n        server.start(num_processes=1)\n\n        self.ioloop.start()\n", "path": "gunicorn/workers/gtornado.py"}]}