[Python-checkins] cpython (3.4): Tulip issue 196: _OverlappedFuture.set_result() now clears its reference to the

victor.stinner python-checkins at python.org
Sat Jul 26 00:59:23 CEST 2014


http://hg.python.org/cpython/rev/b95cf0f1bb77
changeset:   91875:b95cf0f1bb77
branch:      3.4
parent:      91873:01c6d2893092
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Sat Jul 26 00:58:34 2014 +0200
summary:
  Tulip issue 196: _OverlappedFuture.set_result() now clears its reference to the
overlapped object. IocpProactor._poll() now also ignores false alarms:
GetQueuedCompletionStatus() returns the overlapped but it is still pending.

files:
  Lib/asyncio/windows_events.py |  16 +++++++++++-----
  1 files changed, 11 insertions(+), 5 deletions(-)


diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -77,6 +77,10 @@
         super().set_exception(exception)
         self._cancel_overlapped()
 
+    def set_result(self, result):
+        super().set_result(result)
+        self._ov = None
+
 
 class _WaitHandleFuture(futures.Future):
     """Subclass of Future which represents a wait handle."""
@@ -478,6 +482,13 @@
                     _winapi.CloseHandle(key)
                 ms = 0
                 continue
+
+            if ov.pending:
+                # False alarm: the overlapped operation is not completed.
+                # FIXME: why do we get false alarms?
+                self._cache[address] = (f, ov, obj, callback)
+                continue
+
             if obj in self._stopped_serving:
                 f.cancel()
             elif not f.cancelled():
@@ -489,11 +500,6 @@
                 else:
                     f.set_result(value)
                     self._results.append(f)
-                    # FIXME, tulip issue #196: add _OverlappedFuture.set_result()
-                    # method to clear the refrence, don't do it here (f may
-                    # by a _WaitHandleFuture). Problem: clearing the reference
-                    # in _register() if ov.pedding is False leads to weird bugs.
-                    f._ov = None
             ms = 0
 
     def _stop_serving(self, obj):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list