Commit 357b5258 authored by Victor Stinner's avatar Victor Stinner

asyncio, Tulip issue 157: Improve test_events.py, avoid run_briefly() which is

not reliable
parent a01770fd
......@@ -21,10 +21,11 @@ try:
except ImportError: # pragma: no cover
ssl = None
from . import tasks
from . import base_events
from . import events
from . import futures
from . import selectors
from . import tasks
if sys.platform == 'win32': # pragma: no cover
......@@ -52,18 +53,14 @@ def run_briefly(loop):
gen.close()
def run_until(loop, pred, timeout=None):
if timeout is not None:
deadline = time.time() + timeout
def run_until(loop, pred, timeout=30):
deadline = time.time() + timeout
while not pred():
if timeout is not None:
timeout = deadline - time.time()
if timeout <= 0:
return False
loop.run_until_complete(tasks.sleep(timeout, loop=loop))
else:
run_briefly(loop)
return True
raise futures.TimeoutError()
loop.run_until_complete(tasks.sleep(0.001, loop=loop))
def run_once(loop):
......
This diff is collapsed.
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