all child processes exit cleanly.
raise RuntimeError("Too many child restarts, giving up")
new_id = start_child(id)
if new_id is not None: return new_id
+ # All child processes exited cleanly, so exit the master process
+ # instead of just returning to right after the call to
+ # fork_processes (which will probably just start up another IOLoop
+ # unless the caller checks the return value).
+ sys.exit(0)
def task_id():
"""Returns the current task id, if any.
sockets = bind_sockets(port, "127.0.0.1")
# ensure that none of these processes live too long
signal.alarm(5) # master process
- id = fork_processes(3, max_restarts=3)
- if id is None:
- # back in the master process; everything worked!
+ try:
+ id = fork_processes(3, max_restarts=3)
+ except SystemExit, e:
+ # if we exit cleanly from fork_processes, all the child processes
+ # finished with status 0
+ self.assertEqual(e.code, 0)
self.assertTrue(task_id() is None)
for sock in sockets: sock.close()
signal.alarm(0)
In progress
-----------
+Backwards-incompatible changes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* `tornado.process.fork_processes` now raises `SystemExit` if all child
+ processes exit cleanly rather than returning ``None``. The old behavior
+ was surprising and inconsistent with most of the documented examples
+ of this function (which did not check the return value).
+
``IOLoop`` and ``IOStream``
~~~~~~~~~~~~~~~~~~~~~~~~~~~