Commit c110b876 authored by Denis Bilenko's avatar Denis Bilenko

add test_hub_join_timeout.py

parent 620691c7
import gevent
from time import time
SMALL = 0.1
FUZZY = SMALL / 2
for _a in xrange(2):
for _b in xrange(2):
gevent.spawn_later(SMALL, lambda: 5)
start = time()
result = gevent.get_hub().join(timeout=10)
assert result is True, repr(result)
delay = time() - start
assert SMALL - FUZZY <= delay <= SMALL + FUZZY, delay
for _c in xrange(2):
gevent.spawn_later(10, lambda: 5)
start = time()
result = gevent.get_hub().join(timeout=SMALL)
assert result is None, repr(result)
delay = time() - start
assert SMALL - FUZZY <= delay <= SMALL + FUZZY, delay
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