bpo-35727: Use exit code 0 on sys.exit() in multiprocessing.Process. (GH-11538)
This commit is contained in:
parent
baf29b2216
commit
c2ac4cf040
|
@ -317,12 +317,12 @@ class BaseProcess(object):
|
||||||
finally:
|
finally:
|
||||||
util._exit_function()
|
util._exit_function()
|
||||||
except SystemExit as e:
|
except SystemExit as e:
|
||||||
if not e.args:
|
if e.code is None:
|
||||||
exitcode = 1
|
exitcode = 0
|
||||||
elif isinstance(e.args[0], int):
|
elif isinstance(e.code, int):
|
||||||
exitcode = e.args[0]
|
exitcode = e.code
|
||||||
else:
|
else:
|
||||||
sys.stderr.write(str(e.args[0]) + '\n')
|
sys.stderr.write(str(e.code) + '\n')
|
||||||
exitcode = 1
|
exitcode = 1
|
||||||
except:
|
except:
|
||||||
exitcode = 1
|
exitcode = 1
|
||||||
|
|
|
@ -864,12 +864,21 @@ class _TestSubclassingProcess(BaseTestCase):
|
||||||
|
|
||||||
os.unlink(testfn)
|
os.unlink(testfn)
|
||||||
|
|
||||||
for reason in (True, False, 8):
|
cases = [
|
||||||
p = self.Process(target=sys.exit, args=(reason,))
|
((True,), 1),
|
||||||
p.daemon = True
|
((False,), 0),
|
||||||
p.start()
|
((8,), 8),
|
||||||
join_process(p)
|
((None,), 0),
|
||||||
self.assertEqual(p.exitcode, reason)
|
((), 0),
|
||||||
|
]
|
||||||
|
|
||||||
|
for args, expected in cases:
|
||||||
|
with self.subTest(args=args):
|
||||||
|
p = self.Process(target=sys.exit, args=args)
|
||||||
|
p.daemon = True
|
||||||
|
p.start()
|
||||||
|
join_process(p)
|
||||||
|
self.assertEqual(p.exitcode, expected)
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
|
@ -746,6 +746,7 @@ Lawrence Hudson
|
||||||
Michael Hudson
|
Michael Hudson
|
||||||
Jim Hugunin
|
Jim Hugunin
|
||||||
Greg Humphreys
|
Greg Humphreys
|
||||||
|
Chris Hunt
|
||||||
Eric Huss
|
Eric Huss
|
||||||
Nehal Hussain
|
Nehal Hussain
|
||||||
Taihyun Hwang
|
Taihyun Hwang
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix sys.exit() and sys.exit(None) exit code propagation when used in multiprocessing.Process.
|
Loading…
Reference in New Issue