Christopher Hunt <chrah...@gmail.com> added the comment:

> I believe the mentality behind multiprocessing.Process triggering an exit 
> code of 1 when sys.exit() is invoked inside its process is to indicate a 
> non-standard exit out of its execution.

Can I ask what this is based on? I did a pretty good amount of digging but 
didn't find any justification for it. It just seems like a simple oversight to 
me.

> There may yet be other side effects that could be triggered by having a 
> sys.exit(0) translate into an exit code of 0 from the Process's process -- 
> and we might not notice them with the current tests.

This is definitely a behavior change and will break any code that currently 
relies on `sys.exit(None)` or `sys.exit()` exiting with a non-zero exit code 
from a multiprocessing.Process. The fact that all documentation indicates that 
`sys.exit(None)` or `sys.exit()` results in a 0 exit code in normal Python 
(with no documentation on it related to multiprocessing) makes me think that 
any code relying on this behavior is subtly broken, however. Any impacted user 
can update their code and explicitly pass 1 to `sys.exit`, which should be 
forward and backwards compatible.

> Was there a particular use case that motivates this suggested change?

I have a wrapper library that invokes arbitrary user code and attempts to 
behave as if that code was executed in a vanilla Python process, to include 
propagating the correct exit code.

Currently I have a workaround here: 
https://github.com/chrahunt/quicken/blob/2dd00a5f024d7b114b211aad8a2618ec8f101956/quicken/_internal/server.py#L344-L353,
 but it would be nice to get rid of it in 5-6 years if this fix gets in and the 
non-conformant Python versions fall out of support. :)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35727>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to