This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandjon
Recipients brandjon, jnoller, neologix, pitrou
Date 2012-01-23.18:58:51
SpamBayes Score 1.4105384e-13
Marked as misclassified No
Message-id <1327345132.43.0.775594933755.issue13841@psf.upfronthosting.co.za>
In-reply-to
Content
Currently the multiprocessing library calls a hard exit function (os._exit under unix, ExitProcess under Windows) to terminate the child process.

Under unix, this is necessary because the child is forked without exec-ing. Calling sys.exit() would make it possible for the child to run code on the part of the stack inherited from the parent, via the exception handling mechanism. It might also allow the child to accidentally destroy shared state through an object destructor, even when that object was not explicitly relied on by the child.

Under Windows, I do not see any benefit besides symmetry. Processes are not forked, and the only way control can pass to user code after executing the target function, is if the process is frozen and the user puts the call to freeze_support() inside a try block. This special case can be taken care of by advising the user not to do that. (We already tell the user where freeze_support() should be located.)

Changing the multiprocessing exit routine from ExitProcess to sys.exit on Windows would ensure that all objects holding resources get properly destroyed. In particular, it would ensure that all file streams (including standard output and standard error) are flushed. This is especially important under Python 3, since the new IO system uses its own buffering which cannot be flushed by ExitProcess -- from the user's point of view, a potential regression from Python 2.x.

Related issues:
  - #13812 would not have been a problem under windows.
  - If #8713 gets adopted, unix can use sys.exit() as well.
History
Date User Action Args
2012-01-23 18:58:52brandjonsetrecipients: + brandjon, pitrou, jnoller, neologix
2012-01-23 18:58:52brandjonsetmessageid: <1327345132.43.0.775594933755.issue13841@psf.upfronthosting.co.za>
2012-01-23 18:58:51brandjonlinkissue13841 messages
2012-01-23 18:58:51brandjoncreate