Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ef909c

Browse files
committed
Fix for issue 14725 for 3.2 branch
1 parent 16f6f83 commit 7ef909c

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

Lib/multiprocessing/connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,10 @@ def accept(self):
360360
try:
361361
win32.ConnectNamedPipe(handle, win32.NULL)
362362
except WindowsError as e:
363-
if e.args[0] != win32.ERROR_PIPE_CONNECTED:
363+
# ERROR_NO_DATA can occur if a client has already connected,
364+
# written data and then disconnected -- see Issue 14725.
365+
if e.args[0] not in (win32.ERROR_PIPE_CONNECTED,
366+
win32.ERROR_NO_DATA):
364367
raise
365368
return _multiprocessing.PipeConnection(handle)
366369

Lib/test/test_multiprocessing.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,23 @@ def test_listener_client(self):
17321732
self.assertEqual(conn.recv(), 'hello')
17331733
p.join()
17341734
l.close()
1735+
1736+
def test_issue14725(self):
1737+
l = self.connection.Listener()
1738+
p = self.Process(target=self._test, args=(l.address,))
1739+
p.daemon = True
1740+
p.start()
1741+
time.sleep(1)
1742+
# On Windows the client process should by now have connected,
1743+
# written data and closed the pipe handle by now. This causes
1744+
# ConnectNamdedPipe() to fail with ERROR_NO_DATA. See Issue
1745+
# 14725.
1746+
conn = l.accept()
1747+
self.assertEqual(conn.recv(), 'hello')
1748+
conn.close()
1749+
p.join()
1750+
l.close()
1751+
17351752
#
17361753
# Test of sending connection and socket objects between processes
17371754
#

Modules/_multiprocessing/win32_functions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ create_win32_namespace(void)
244244
Py_INCREF(&Win32Type);
245245

246246
WIN32_CONSTANT(F_DWORD, ERROR_ALREADY_EXISTS);
247+
WIN32_CONSTANT(F_DWORD, ERROR_NO_DATA);
247248
WIN32_CONSTANT(F_DWORD, ERROR_PIPE_BUSY);
248249
WIN32_CONSTANT(F_DWORD, ERROR_PIPE_CONNECTED);
249250
WIN32_CONSTANT(F_DWORD, ERROR_SEM_TIMEOUT);

0 commit comments

Comments
 (0)