cpython: 36e80c6599aa (original) (raw)
Mercurial > cpython
changeset 94323:36e80c6599aa 3.4
Issue #23095, asyncio: Fix _WaitHandleFuture.cancel() If UnregisterWaitEx() fais with ERROR_IO_PENDING, it doesn't mean that the wait is unregistered yet. We still have to wait until the wait is cancelled. [#23095]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Mon, 26 Jan 2015 22:30:28 +0100 |
parents | 99c3e304a4ea |
children | 9532923cbf2b |
files | Lib/asyncio/windows_events.py |
diffstat | 1 files changed, 17 insertions(+), 20 deletions(-)[+] [-] Lib/asyncio/windows_events.py 37 |
line wrap: on
line diff
--- a/Lib/asyncio/windows_events.py +++ b/Lib/asyncio/windows_events.py @@ -126,14 +126,12 @@ class _BaseWaitHandleFuture(futures.Futu return self._registered = False
wait_handle = self._wait_handle[](#l1.7)
self._wait_handle = None[](#l1.8) try:[](#l1.9)
_overlapped.UnregisterWait(self._wait_handle)[](#l1.10)
_overlapped.UnregisterWait(wait_handle)[](#l1.11) except OSError as exc:[](#l1.12)
self._wait_handle = None[](#l1.13)
if exc.winerror == _overlapped.ERROR_IO_PENDING:[](#l1.14)
# ERROR_IO_PENDING is not an error, the wait was unregistered[](#l1.15)
self._unregister_wait_cb(None)[](#l1.16)
elif exc.winerror != _overlapped.ERROR_IO_PENDING:[](#l1.17)
if exc.winerror != _overlapped.ERROR_IO_PENDING:[](#l1.18) context = {[](#l1.19) 'message': 'Failed to unregister the wait handle',[](#l1.20) 'exception': exc,[](#l1.21)
@@ -142,9 +140,10 @@ class _BaseWaitHandleFuture(futures.Futu if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context)
else:[](#l1.26)
self._wait_handle = None[](#l1.27)
self._unregister_wait_cb(None)[](#l1.28)
return[](#l1.29)
# ERROR_IO_PENDING means that the unregister is pending[](#l1.30)
self._unregister_wait_cb(None)[](#l1.32)
def cancel(self): self._unregister_wait() @@ -209,14 +208,12 @@ class _WaitHandleFuture(_BaseWaitHandleF return self._registered = False
wait_handle = self._wait_handle[](#l1.40)
self._wait_handle = None[](#l1.41) try:[](#l1.42)
_overlapped.UnregisterWaitEx(self._wait_handle, self._event)[](#l1.43)
_overlapped.UnregisterWaitEx(wait_handle, self._event)[](#l1.44) except OSError as exc:[](#l1.45)
self._wait_handle = None[](#l1.46)
if exc.winerror == _overlapped.ERROR_IO_PENDING:[](#l1.47)
# ERROR_IO_PENDING is not an error, the wait was unregistered[](#l1.48)
self._unregister_wait_cb(None)[](#l1.49)
elif exc.winerror != _overlapped.ERROR_IO_PENDING:[](#l1.50)
if exc.winerror != _overlapped.ERROR_IO_PENDING:[](#l1.51) context = {[](#l1.52) 'message': 'Failed to unregister the wait handle',[](#l1.53) 'exception': exc,[](#l1.54)
@@ -225,11 +222,11 @@ class _WaitHandleFuture(_BaseWaitHandleF if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context)
else:[](#l1.59)
self._wait_handle = None[](#l1.60)
self._event_fut = self._proactor._wait_cancel([](#l1.61)
self._event,[](#l1.62)
self._unregister_wait_cb)[](#l1.63)
return[](#l1.64)
# ERROR_IO_PENDING is not an error, the wait was unregistered[](#l1.65)
self._event_fut = self._proactor._wait_cancel(self._event,[](#l1.67)
self._unregister_wait_cb)[](#l1.68)