Commit a01fb398 authored by Richard Oudkerk's avatar Richard Oudkerk

Issue #18762: Print debug info on failure to create new forkserver process.

Also modify test code to hopefully avoid deadlock on failure.
parent 6acbe2aa
...@@ -66,6 +66,21 @@ def connect_to_new_process(fds): ...@@ -66,6 +66,21 @@ def connect_to_new_process(fds):
try: try:
reduction.sendfds(client, allfds) reduction.sendfds(client, allfds)
return parent_r, parent_w return parent_r, parent_w
except OSError:
# XXX This is debugging info for Issue #18762
import fcntl
L = []
for fd in allfds:
try:
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
except OSError as e:
L.append((fd, e))
else:
L.append((fd, flags))
print('*** connect_to_new_process: %r' % L, file=sys.stderr)
os.close(parent_r)
os.close(parent_w)
raise
except: except:
os.close(parent_r) os.close(parent_r)
os.close(parent_w) os.close(parent_w)
......
...@@ -3386,7 +3386,8 @@ class TestForkAwareThreadLock(unittest.TestCase): ...@@ -3386,7 +3386,8 @@ class TestForkAwareThreadLock(unittest.TestCase):
if n > 1: if n > 1:
p = multiprocessing.Process(target=cls.child, args=(n-1, conn)) p = multiprocessing.Process(target=cls.child, args=(n-1, conn))
p.start() p.start()
p.join() conn.close()
p.join(timeout=5)
else: else:
conn.send(len(util._afterfork_registry)) conn.send(len(util._afterfork_registry))
conn.close() conn.close()
...@@ -3397,8 +3398,9 @@ class TestForkAwareThreadLock(unittest.TestCase): ...@@ -3397,8 +3398,9 @@ class TestForkAwareThreadLock(unittest.TestCase):
old_size = len(util._afterfork_registry) old_size = len(util._afterfork_registry)
p = multiprocessing.Process(target=self.child, args=(5, w)) p = multiprocessing.Process(target=self.child, args=(5, w))
p.start() p.start()
w.close()
new_size = r.recv() new_size = r.recv()
p.join() p.join(timeout=5)
self.assertLessEqual(new_size, old_size) self.assertLessEqual(new_size, old_size)
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment