aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/multiprocessing/forkserver.py
diff options
context:
space:
mode:
authorAllen W. Smith, Ph.D <drallensmith@users.noreply.github.com>2017-08-29 17:52:18 -0500
committerAntoine Pitrou <pitrou@free.fr>2017-08-30 00:52:18 +0200
commitbd73e72b4a9f019be514954b1d40e64dc3a5e81c (patch)
tree8f66dfa1db72d2fe3eae557883434baadecb85e2 /Lib/multiprocessing/forkserver.py
parent631fdee6e61b4ba8ce800f827fecdd536bfb04f3 (diff)
downloadcpython-bd73e72b4a9f019be514954b1d40e64dc3a5e81c.tar.gz
cpython-bd73e72b4a9f019be514954b1d40e64dc3a5e81c.zip
bpo-5001: More-informative multiprocessing error messages (#3079)
* Make error message more informative Replace assertions in error-reporting code with more-informative version that doesn't cause confusion over where and what the error is. * Additional clarification + get travis to check * Change from SystemError to TypeError As suggested in PR comment by @pitrou, changing from SystemError; TypeError appears appropriate. * NEWS file installation; ACKS addition (will do my best to justify it by additional work) * Making current AssertionErrors in multiprocessing more informative * Blurb added re multiprocessing managers.py, queues.py cleanup * Further multiprocessing cleanup - went through pool.py * Fix two asserts in multiprocessing/util.py * Most asserts in multiprocessing more informative * Didn't save right version * Further work on multiprocessing error messages * Correct typo * Correct typo v2 * Blasted colon... serves me right for trying to work on two things at once * Simplify NEWS entry * Update 2017-08-18-17-16-38.bpo-5001.gwnthq.rst * Update 2017-08-18-17-16-38.bpo-5001.gwnthq.rst OK, never mind. * Corrected (thanks to pitrou) error messages for notify * Remove extraneous backslash in docstring.
Diffstat (limited to 'Lib/multiprocessing/forkserver.py')
-rw-r--r--Lib/multiprocessing/forkserver.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/multiprocessing/forkserver.py b/Lib/multiprocessing/forkserver.py
index 69b842aa939..7a952e2ba69 100644
--- a/Lib/multiprocessing/forkserver.py
+++ b/Lib/multiprocessing/forkserver.py
@@ -189,7 +189,7 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None):
if alive_r in rfds:
# EOF because no more client processes left
- assert os.read(alive_r, 1) == b''
+ assert os.read(alive_r, 1) == b'', "Not at EOF?"
raise SystemExit
if sig_r in rfds:
@@ -208,7 +208,10 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None):
if os.WIFSIGNALED(sts):
returncode = -os.WTERMSIG(sts)
else:
- assert os.WIFEXITED(sts)
+ if not os.WIFEXITED(sts):
+ raise AssertionError(
+ "Child {0:n} status is {1:n}".format(
+ pid,sts))
returncode = os.WEXITSTATUS(sts)
# Send exit code to client process
try:
@@ -227,7 +230,10 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None):
with listener.accept()[0] as s:
# Receive fds from client
fds = reduction.recvfds(s, MAXFDS_TO_SEND + 1)
- assert len(fds) <= MAXFDS_TO_SEND
+ if len(fds) > MAXFDS_TO_SEND:
+ raise RuntimeError(
+ "Too many ({0:n}) fds to send".format(
+ len(fds)))
child_r, child_w, *fds = fds
s.close()
pid = os.fork()