Unverified Commit f88e8401 authored by Nick Hill's avatar Nick Hill Committed by GitHub
Browse files

[BugFix] Fix async core engine client finalizer (#24540)


Signed-off-by: default avatarNick Hill <nhill@redhat.com>
parent 3c2156b3
...@@ -347,8 +347,9 @@ class BackgroundResources: ...@@ -347,8 +347,9 @@ class BackgroundResources:
if isinstance(self.output_socket, zmq.asyncio.Socket): if isinstance(self.output_socket, zmq.asyncio.Socket):
# Async case. # Async case.
loop = self.output_socket._get_loop() loop = self.output_queue_task._loop \
asyncio.get_running_loop() if self.output_queue_task else None
sockets = (self.output_socket, self.input_socket, sockets = (self.output_socket, self.input_socket,
self.first_req_send_socket, self.first_req_rcv_socket, self.first_req_send_socket, self.first_req_rcv_socket,
self.stats_update_socket) self.stats_update_socket)
...@@ -359,11 +360,12 @@ class BackgroundResources: ...@@ -359,11 +360,12 @@ class BackgroundResources:
close_sockets(sockets) close_sockets(sockets)
for task in tasks: for task in tasks:
if task is not None and not task.done(): if task is not None and not task.done():
with contextlib.suppress(Exception):
task.cancel() task.cancel()
if in_loop(loop): if in_loop(loop):
close_sockets_and_tasks() close_sockets_and_tasks()
elif not loop.is_closed(): elif loop and not loop.is_closed():
loop.call_soon_threadsafe(close_sockets_and_tasks) loop.call_soon_threadsafe(close_sockets_and_tasks)
else: else:
# Loop has been closed, try to clean up directly. # Loop has been closed, try to clean up directly.
......
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