From 73d9a292aeed5aa3414c911c1f34afeea17f0dda Mon Sep 17 00:00:00 2001 From: Richard Oudkerk Date: Thu, 14 Jun 2012 15:30:10 +0100 Subject: Issue #13841: Make child processes exit using sys.exit() on Windows --- Lib/multiprocessing/util.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'Lib/multiprocessing/util.py') diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py index 48abe383fa..8a6aede162 100644 --- a/Lib/multiprocessing/util.py +++ b/Lib/multiprocessing/util.py @@ -269,21 +269,24 @@ _exiting = False def _exit_function(): global _exiting - info('process shutting down') - debug('running all "atexit" finalizers with priority >= 0') - _run_finalizers(0) + if not _exiting: + _exiting = True - for p in active_children(): - if p._daemonic: - info('calling terminate() for daemon %s', p.name) - p._popen.terminate() + info('process shutting down') + debug('running all "atexit" finalizers with priority >= 0') + _run_finalizers(0) - for p in active_children(): - info('calling join() for process %s', p.name) - p.join() + for p in active_children(): + if p._daemonic: + info('calling terminate() for daemon %s', p.name) + p._popen.terminate() - debug('running the remaining "atexit" finalizers') - _run_finalizers() + for p in active_children(): + info('calling join() for process %s', p.name) + p.join() + + debug('running the remaining "atexit" finalizers') + _run_finalizers() atexit.register(_exit_function) -- cgit v1.2.1