Kaydet (Commit) 48c66c3d authored tarafından Guido van Rossum's avatar Guido van Rossum

asyncio: wait_for() now accepts None as timeout (Victor Stinner).

üst 1e9a446e
......@@ -394,6 +394,9 @@ def wait_for(fut, timeout, *, loop=None):
if loop is None:
loop = events.get_event_loop()
if timeout is None:
return (yield from fut)
waiter = futures.Future(loop=loop)
timeout_handle = loop.call_later(timeout, _release_waiter, waiter, False)
cb = functools.partial(_release_waiter, waiter, True)
......
......@@ -380,6 +380,17 @@ class TaskTests(unittest.TestCase):
self.assertEqual(foo_running, False)
def test_wait_for_blocking(self):
loop = test_utils.TestLoop()
self.addCleanup(loop.close)
@asyncio.coroutine
def coro():
return 'done'
res = loop.run_until_complete(asyncio.wait_for(coro(), timeout=None, loop=loop))
self.assertEqual(res, 'done')
def test_wait_for_with_global_loop(self):
def gen():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment