MCPcopy
hub / github.com/benoitc/gunicorn / run

Method run

gunicorn/workers/gtornado.py:75–124  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73 super().init_process()
74
75 def run(self):
76 self.ioloop = IOLoop.instance()
77 self.alive = True
78 self.server_alive = False
79
80 # Warn if HTTP/2 is requested - tornado worker doesn't support it
81 if 'h2' in self.cfg.http_protocols:
82 self.log.warning(
83 "HTTP/2 is not supported by the tornado worker. "
84 "Use gthread, gevent, or asgi workers for HTTP/2 support. "
85 "Falling back to HTTP/1.1 only."
86 )
87
88 self.callbacks = []
89 self.callbacks.append(PeriodicCallback(self.watchdog, 1000))
90 self.callbacks.append(PeriodicCallback(self.heartbeat, 1000))
91 for callback in self.callbacks:
92 callback.start()
93
94 # Assume the app is a WSGI callable if its not an
95 # instance of tornado.web.Application or WSGIContainer
96 app = self.wsgi
97 if not isinstance(app, WSGIContainer) and \
98 not isinstance(app, tornado.web.Application):
99 app = WSGIContainer(app)
100
101 worker = self
102
103 class _HTTPServer(tornado.httpserver.HTTPServer):
104
105 def on_close(self, server_conn):
106 worker.handle_request()
107 super().on_close(server_conn)
108
109 if self.cfg.is_ssl:
110 server = _HTTPServer(app, ssl_options=ssl_context(self.cfg))
111 else:
112 server = _HTTPServer(app)
113
114 self.server = server
115 self.server_alive = True
116
117 for s in self.sockets:
118 s.setblocking(0)
119 server.add_socket(s)
120
121 server.no_keep_alive = self.cfg.keepalive <= 0
122 server.start(num_processes=1)
123
124 self.ioloop.start()

Callers

nothing calls this directly

Calls 5

ssl_contextFunction · 0.90
_HTTPServerClass · 0.85
warningMethod · 0.45
startMethod · 0.45
setblockingMethod · 0.45

Tested by

no test coverage detected