[Python-checkins] cpython (merge 3.4 -> default): Issue #18382: Zero-length messages are consumed by ReadFile on Windows 8 and
steve.dower
python-checkins at python.org
Mon Mar 2 17:06:45 CET 2015
https://hg.python.org/cpython/rev/6ccbcf1df7bd
changeset: 94826:6ccbcf1df7bd
parent: 94824:57e2549cc9a6
parent: 94825:7401a28d3d41
user: Steve Dower <steve.dower at microsoft.com>
date: Mon Mar 02 08:06:30 2015 -0800
summary:
Issue #18382: Zero-length messages are consumed by ReadFile on Windows 8 and later
files:
Lib/multiprocessing/connection.py | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -829,7 +829,7 @@
try:
ov, err = _winapi.ReadFile(fileno(), 0, True)
except OSError as e:
- err = e.winerror
+ ov, err = None, e.winerror
if err not in _ready_errors:
raise
if err == _winapi.ERROR_IO_PENDING:
@@ -838,7 +838,16 @@
else:
# If o.fileno() is an overlapped pipe handle and
# err == 0 then there is a zero length message
- # in the pipe, but it HAS NOT been consumed.
+ # in the pipe, but it HAS NOT been consumed...
+ if ov and sys.getwindowsversion()[:2] >= (6, 2):
+ # ... except on Windows 8 and later, where
+ # the message HAS been consumed.
+ try:
+ _, err = ov.GetOverlappedResult(False)
+ except OSError as e:
+ err = e.winerror
+ if not err and hasattr(o, '_got_empty_message'):
+ o._got_empty_message = True
ready_objects.add(o)
timeout = 0
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list