Starts this server in the `.IOLoop`. By default, we run the server in this process and do not fork any additional child process. If num_processes is ``None`` or <= 0, we detect the number of cores available on this machine and fork that number of child proce
(
self, num_processes: Optional[int] = 1, max_restarts: Optional[int] = None
)
| 264 | self._pending_sockets.extend(sockets) |
| 265 | |
| 266 | def start( |
| 267 | self, num_processes: Optional[int] = 1, max_restarts: Optional[int] = None |
| 268 | ) -> None: |
| 269 | """Starts this server in the `.IOLoop`. |
| 270 | |
| 271 | By default, we run the server in this process and do not fork any |
| 272 | additional child process. |
| 273 | |
| 274 | If num_processes is ``None`` or <= 0, we detect the number of cores |
| 275 | available on this machine and fork that number of child |
| 276 | processes. If num_processes is given and > 1, we fork that |
| 277 | specific number of sub-processes. |
| 278 | |
| 279 | Since we use processes and not threads, there is no shared memory |
| 280 | between any server code. |
| 281 | |
| 282 | Note that multiple processes are not compatible with the autoreload |
| 283 | module (or the ``autoreload=True`` option to `tornado.web.Application` |
| 284 | which defaults to True when ``debug=True``). |
| 285 | When using multiple processes, no IOLoops can be created or |
| 286 | referenced until after the call to ``TCPServer.start(n)``. |
| 287 | |
| 288 | Values of ``num_processes`` other than 1 are not supported on Windows. |
| 289 | |
| 290 | The ``max_restarts`` argument is passed to `.fork_processes`. |
| 291 | |
| 292 | .. versionchanged:: 6.0 |
| 293 | |
| 294 | Added ``max_restarts`` argument. |
| 295 | |
| 296 | .. deprecated:: 6.2 |
| 297 | Use either ``listen()`` or ``add_sockets()`` instead of ``bind()`` |
| 298 | and ``start()``. The ``bind()/start()`` pattern depends on |
| 299 | interfaces that have been deprecated in Python 3.10 and will be |
| 300 | removed in future versions of Python. |
| 301 | """ |
| 302 | assert not self._started |
| 303 | self._started = True |
| 304 | if num_processes != 1: |
| 305 | process.fork_processes(num_processes, max_restarts) |
| 306 | sockets = self._pending_sockets |
| 307 | self._pending_sockets = [] |
| 308 | self.add_sockets(sockets) |
| 309 | |
| 310 | def stop(self) -> None: |
| 311 | """Stops listening for new connections. |
nothing calls this directly
no test coverage detected