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

Skip to content

Commit af52903

Browse files
committed
(Merge 3.4) 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.
2 parents a22d823 + 51e44ea commit af52903

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Lib/asyncio/windows_events.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def set_exception(self, exception):
7777
super().set_exception(exception)
7878
self._cancel_overlapped()
7979

80+
def set_result(self, result):
81+
super().set_result(result)
82+
self._ov = None
83+
8084

8185
class _WaitHandleFuture(futures.Future):
8286
"""Subclass of Future which represents a wait handle."""
@@ -478,6 +482,13 @@ def _poll(self, timeout=None):
478482
_winapi.CloseHandle(key)
479483
ms = 0
480484
continue
485+
486+
if ov.pending:
487+
# False alarm: the overlapped operation is not completed.
488+
# FIXME: why do we get false alarms?
489+
self._cache[address] = (f, ov, obj, callback)
490+
continue
491+
481492
if obj in self._stopped_serving:
482493
f.cancel()
483494
elif not f.cancelled():
@@ -489,11 +500,6 @@ def _poll(self, timeout=None):
489500
else:
490501
f.set_result(value)
491502
self._results.append(f)
492-
# FIXME, tulip issue #196: add _OverlappedFuture.set_result()
493-
# method to clear the refrence, don't do it here (f may
494-
# by a _WaitHandleFuture). Problem: clearing the reference
495-
# in _register() if ov.pedding is False leads to weird bugs.
496-
f._ov = None
497503
ms = 0
498504

499505
def _stop_serving(self, obj):

0 commit comments

Comments
 (0)