Handle async clients when closing
@@ -4726,6 +4726,9 @@ def _close_global_client():
if c is not None:
c._should_close_loop = False
with suppress(TimeoutError, RuntimeError):
+ if c.asynchronous:
+ c.loop.add_callback(c.close, timeout=3)
+ else:
c.close(timeout=3)
