_task_id = None
-def fork_processes(num_processes: Optional[int], max_restarts: int = 100) -> int:
+def fork_processes(num_processes: Optional[int], max_restarts: int = None) -> int:
"""Starts multiple worker processes.
If ``num_processes`` is None or <= 0, we detect the number of cores
process, ``fork_processes`` returns None if all child processes
have exited normally, but will otherwise only exit by throwing an
exception.
+
+ max_restarts defaults to 100.
"""
+ if max_restarts is None:
+ max_restarts = 100
+
global _task_id
assert _task_id is None
if num_processes is None or num_processes <= 0:
else:
self._pending_sockets.extend(sockets)
- def start(self, num_processes: Optional[int] = 1) -> None:
+ def start(self, num_processes: Optional[int] = 1, max_restarts: int = None) -> None:
"""Starts this server in the `.IOLoop`.
By default, we run the server in this process and do not fork any
assert not self._started
self._started = True
if num_processes != 1:
- process.fork_processes(num_processes)
+ process.fork_processes(num_processes, max_restarts)
sockets = self._pending_sockets
self._pending_sockets = []
self.add_sockets(sockets)