(self)
| 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() |
nothing calls this directly
no test coverage detected