[Python-checkins] cpython (2.7): Fix for issue 14725 for 2.7 branch
richard.oudkerk
python-checkins at python.org
Sat May 5 21:59:38 CEST 2012
http://hg.python.org/cpython/rev/35ef949e85d7
changeset: 76772:35ef949e85d7
branch: 2.7
parent: 76751:8215aaccc9dd
user: Richard Oudkerk <shibturn at gmail.com>
date: Sat May 05 20:41:08 2012 +0100
summary:
Fix for issue 14725 for 2.7 branch
files:
Lib/multiprocessing/connection.py | 5 ++-
Lib/test/test_multiprocessing.py | 17 ++++++++++
Modules/_multiprocessing/win32_functions.c | 1 +
3 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -348,7 +348,10 @@
try:
win32.ConnectNamedPipe(handle, win32.NULL)
except WindowsError, 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
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1669,6 +1669,23 @@
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
#
diff --git a/Modules/_multiprocessing/win32_functions.c b/Modules/_multiprocessing/win32_functions.c
--- a/Modules/_multiprocessing/win32_functions.c
+++ b/Modules/_multiprocessing/win32_functions.c
@@ -244,6 +244,7 @@
Py_INCREF(&Win32Type);
WIN32_CONSTANT(F_DWORD, ERROR_ALREADY_EXISTS);
+ WIN32_CONSTANT(F_DWORD, ERROR_NO_DATA);
WIN32_CONSTANT(F_DWORD, ERROR_PIPE_BUSY);
WIN32_CONSTANT(F_DWORD, ERROR_PIPE_CONNECTED);
WIN32_CONSTANT(F_DWORD, ERROR_SEM_TIMEOUT);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list