New submission from Brodie Rao:
Normally:
$ python
>>> import sys
>>> sys.exit('foo')
foo
$ echo $?
1
However, with multiprocessing:
>>> import sys
>>> from multiprocessing import Process
>>> p = Process(target=lambda: sys.exit('foo'))
>>> p.start()
>>> foo
>>> p.join()
>>> p.is_alive()
False
>>> p.exitcode
0
p.exitcode should be 1, not 0. sys.exit() with a non-int object should always
exit with 1.
This regression was introduced in da5b370f41a1 on the 2.7 branch (making it
into the 2.7.4 release) and 4346cba353b4 on the 3.2 branch (making it into the
3.2.5 release).
Less important things to note:
- multiprocessing calls str() on the object passed to sys.exit() to print it
out. The interpreter doesn't do that with the argument is a unicode object (it
tries to let sys.stderr encode it and print it).
- The interpreter also ignores all exceptions in this process.
I'll attach patches for the 2.7 and 3.3 branches that just addresses the exit
code problem.
----------
components: Library (Lib)
messages: 200833
nosy: brodie
priority: normal
severity: normal
status: open
title: multiprocessing: sys.exit() from a child with a non-int exit code exits
with 0
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue19338>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com