For better similarity to Event.wait().
"""
async def wait_timeout(self, timeout):
- await asyncio.wait_for(self.wait(), timeout)
+ try:
+ return await asyncio.wait_for(self.wait(), timeout)
+ except asyncio.TimeoutError:
+ return False
class Queue(queue.Queue): # type: ignore[type-arg] # can be dropped after Python 3.8
with pool.ConnectionPool(
proxy.client_dsn, min_size=4, reconnect_timeout=1.0, reconnect_failed=failed
) as p:
- ev.wait(2.0)
+ assert ev.wait(2.0)
with pytest.raises(pool.PoolTimeout):
with p.connection(timeout=0.5) as conn:
pass
ev.clear()
- ev.wait(2.0)
+ assert ev.wait(2.0)
proxy.start()
# Checking the pool will empty it
p.check()
- ev.wait(2.0)
+ assert ev.wait(2.0)
assert len(p._pool) == 0
# Allow to connect again
tasks = [spawn(worker, (i,)) for i in range(nconns * 3)]
# wait until the pool has served all the connections and clients are queued.
- ev.wait(3.0)
+ assert ev.wait(3.0)
for i in range(10):
if p.get_stats().get("requests_queued", 0):
break
async with pool.AsyncConnectionPool(
proxy.client_dsn, min_size=4, reconnect_timeout=1.0, reconnect_failed=failed
) as p:
- await ev.wait_timeout(2.0)
+ assert await ev.wait_timeout(2.0)
with pytest.raises(pool.PoolTimeout):
async with p.connection(timeout=0.5) as conn:
pass
ev.clear()
- await ev.wait_timeout(2.0)
+ assert await ev.wait_timeout(2.0)
proxy.start()
# Checking the pool will empty it
await p.check()
- await ev.wait_timeout(2.0)
+ assert await ev.wait_timeout(2.0)
assert len(p._pool) == 0
# Allow to connect again
tasks = [spawn(worker, (i,)) for i in range(nconns * 3)]
# wait until the pool has served all the connections and clients are queued.
- await ev.wait_timeout(3.0)
+ assert await ev.wait_timeout(3.0)
for i in range(10):
if p.get_stats().get("requests_queued", 0):
break
tasks = [spawn(worker, (i,)) for i in range(nconns * 3)]
# wait until the pool has served all the connections and clients are queued.
- ev.wait(3.0)
+ assert ev.wait(3.0)
for i in range(10):
if p.get_stats().get("requests_queued", 0):
break
tasks = [spawn(worker, (i,)) for i in range(nconns * 3)]
# wait until the pool has served all the connections and clients are queued.
- await ev.wait_timeout(3.0)
+ assert await ev.wait_timeout(3.0)
for i in range(10):
if p.get_stats().get("requests_queued", 0):
break
tasks = [spawn(worker, (i,)) for i in range(nconns * 3)]
# wait until the pool has served all the connections and clients are queued.
- ev.wait(3.0)
+ assert ev.wait(3.0)
for i in range(10):
if p.get_stats().get("requests_queued", 0):
break
tasks = [spawn(worker, (i,)) for i in range(nconns * 3)]
# wait until the pool has served all the connections and clients are queued.
- await ev.wait_timeout(3.0)
+ assert await ev.wait_timeout(3.0)
for i in range(10):
if p.get_stats().get("requests_queued", 0):
break