summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-12-19 17:10:44 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-12-19 17:10:44 +0100
commit450e721110475c5d5f6941d865178c71b7f4b1e7 (patch)
tree304b85f289503f55818d81efdc66510008f2e0b1 /Lib
parent132a715a502fb06b2ea854ff67b05e6ef93a87f9 (diff)
downloadcpython-450e721110475c5d5f6941d865178c71b7f4b1e7.tar.gz
asyncio: IocpProactor.wait_for_handle() test now also checks the result of the
future
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/windows_events.py5
-rw-r--r--Lib/test/test_asyncio/test_windows_events.py8
2 files changed, 11 insertions, 2 deletions
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index 0773d061f7..d7feb1aec8 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -427,6 +427,11 @@ class IocpProactor:
return self._register(ov, None, finish_connect_pipe, wait_for_post=True)
def wait_for_handle(self, handle, timeout=None):
+ """Wait for a handle.
+
+ Return a Future object. The result of the future is True if the wait
+ completed, or False if the wait did not complete (on timeout).
+ """
if timeout is None:
ms = _winapi.INFINITE
else:
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index b4d9398fb3..9b264a64b0 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -98,8 +98,10 @@ class ProactorTests(test_utils.TestCase):
# result should be False at timeout
fut = self.loop._proactor.wait_for_handle(event, 0.5)
start = self.loop.time()
- self.loop.run_until_complete(fut)
+ done = self.loop.run_until_complete(fut)
elapsed = self.loop.time() - start
+
+ self.assertEqual(done, False)
self.assertFalse(fut.result())
self.assertTrue(0.48 < elapsed < 0.9, elapsed)
@@ -109,8 +111,10 @@ class ProactorTests(test_utils.TestCase):
# result should be True immediately
fut = self.loop._proactor.wait_for_handle(event, 10)
start = self.loop.time()
- self.loop.run_until_complete(fut)
+ done = self.loop.run_until_complete(fut)
elapsed = self.loop.time() - start
+
+ self.assertEqual(done, True)
self.assertTrue(fut.result())
self.assertTrue(0 <= elapsed < 0.3, elapsed)