get_running_loop = asyncio.get_running_loop
else:
- from .utils.context import asynccontextmanager
+ from ..utils.context import asynccontextmanager
get_running_loop = asyncio.get_event_loop
except Empty:
continue
+ if isinstance(task, tasks.StopWorker):
+ logger.debug(
+ "terminating working thread %s",
+ threading.current_thread().name,
+ )
+ return
+
# Run the task. Make sure don't die in the attempt.
try:
task.run()
"task run %s failed: %s: %s", task, e.__class__.__name__, e
)
- if isinstance(task, tasks.StopWorker):
- logger.debug(
- "terminating working thread %s",
- threading.current_thread().name,
- )
- return
-
class ConnectionAttempt:
"""Keep the state of a connection attempt."""
await p.wait_ready()
ref = weakref.ref(p)
del p
+ await asyncio.sleep(0.1) # TODO: I wish it wasn't needed
assert not ref()
assert not recwarn
p = pool.AsyncConnectionPool(dsn)
ts = [p._sched_runner] + p._workers
del p
- await asyncio.sleep(0.2)
+ await asyncio.sleep(0.1)
for t in ts:
assert not t.is_alive()