[Bugfix] Clean up async client sockets after event loop closure (#57757)
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
@@ -538,10 +538,10 @@ class BackgroundResources:
|
||||
with contextlib.suppress(Exception):
|
||||
task.cancel()
|
||||
|
||||
if loop is not None:
|
||||
if loop is not None and not loop.is_closed():
|
||||
if in_loop(loop):
|
||||
close_sockets_and_tasks()
|
||||
elif not loop.is_closed():
|
||||
else:
|
||||
loop.call_soon_threadsafe(close_sockets_and_tasks)
|
||||
else:
|
||||
# Loop has been closed, try to clean up directly.
|
||||
|
||||
Reference in New Issue
Block a user