summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-11-24 17:50:40 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2013-11-24 17:50:40 (GMT)
commit71196e7f558412ec6465eba9cb8dc147428296d9 (patch)
tree7d245d0e2155af3f8d68eda73ec07d008a7ea731 /Lib/asyncio
parentb5d386314fc9f66f9f69399da9b32bf0b6504033 (diff)
downloadcpython-71196e7f558412ec6465eba9cb8dc147428296d9.zip
cpython-71196e7f558412ec6465eba9cb8dc147428296d9.tar.gz
cpython-71196e7f558412ec6465eba9cb8dc147428296d9.tar.bz2
Issue #19740: Use WaitForSingleObject() instead of trusting TimerOrWaitFired.
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/windows_events.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index 64fe386..b2ed241 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -327,14 +327,21 @@ class IocpProactor:
handle, self._iocp, ov.address, ms)
f = _WaitHandleFuture(wh, loop=self._loop)
- def finish(timed_out, _, ov):
+ def finish(trans, key, ov):
if not f.cancelled():
try:
_overlapped.UnregisterWait(wh)
except OSError as e:
if e.winerror != _overlapped.ERROR_IO_PENDING:
raise
- return not timed_out
+ # Note that this second wait means that we should only use
+ # this with handles types where a successful wait has no
+ # effect. So events or processes are all right, but locks
+ # or semaphores are not. Also note if the handle is
+ # signalled and then quickly reset, then we may return
+ # False even though we have not timed out.
+ return (_winapi.WaitForSingleObject(handle, 0) ==
+ _winapi.WAIT_OBJECT_0)
self._cache[ov.address] = (f, ov, None, finish)
return f