summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/connection.py5
-rw-r--r--Lib/test/test_multiprocessing.py17
2 files changed, 21 insertions, 1 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
index 8bb0a3b..f537a36 100644
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -360,7 +360,10 @@ if sys.platform == 'win32':
try:
win32.ConnectNamedPipe(handle, win32.NULL)
except WindowsError as e:
- if e.args[0] != win32.ERROR_PIPE_CONNECTED:
+ # ERROR_NO_DATA can occur if a client has already connected,
+ # written data and then disconnected -- see Issue 14725.
+ if e.args[0] not in (win32.ERROR_PIPE_CONNECTED,
+ win32.ERROR_NO_DATA):
raise
return _multiprocessing.PipeConnection(handle)
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 298faf7..5f1bba3 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1732,6 +1732,23 @@ class _TestListenerClient(BaseTestCase):
self.assertEqual(conn.recv(), 'hello')
p.join()
l.close()
+
+ def test_issue14725(self):
+ l = self.connection.Listener()
+ p = self.Process(target=self._test, args=(l.address,))
+ p.daemon = True
+ p.start()
+ time.sleep(1)
+ # On Windows the client process should by now have connected,
+ # written data and closed the pipe handle by now. This causes
+ # ConnectNamdedPipe() to fail with ERROR_NO_DATA. See Issue
+ # 14725.
+ conn = l.accept()
+ self.assertEqual(conn.recv(), 'hello')
+ conn.close()
+ p.join()
+ l.close()
+
#
# Test of sending connection and socket objects between processes
#