cpython: d71db7fe4872 (original) (raw)
Mercurial > cpython
changeset 87513:d71db7fe4872
Issue #19740: Use WaitForSingleObject() instead of trusting TimerOrWaitFired. [#19740]
Richard Oudkerk shibturn@gmail.com | |
---|---|
date | Sun, 24 Nov 2013 17:50:40 +0000 |
parents | 2bf4741515a7 |
children | 6e5eab3add6c |
files | Lib/asyncio/windows_events.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-)[+] [-] Lib/asyncio/windows_events.py 11 |
line wrap: on
line diff
--- 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):[](#l1.7)
def finish(trans, key, ov):[](#l1.8) if not f.cancelled():[](#l1.9) try:[](#l1.10) _overlapped.UnregisterWait(wh)[](#l1.11) except OSError as e:[](#l1.12) if e.winerror != _overlapped.ERROR_IO_PENDING:[](#l1.13) raise[](#l1.14)
return not timed_out[](#l1.15)
# Note that this second wait means that we should only use[](#l1.16)
# this with handles types where a successful wait has no[](#l1.17)
# effect. So events or processes are all right, but locks[](#l1.18)
# or semaphores are not. Also note if the handle is[](#l1.19)
# signalled and then quickly reset, then we may return[](#l1.20)
# False even though we have not timed out.[](#l1.21)
return (_winapi.WaitForSingleObject(handle, 0) ==[](#l1.22)
_winapi.WAIT_OBJECT_0)[](#l1.23)