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

[V1] Avoid socket errors during shutdown when requests are in in-flight (#16807)


Signed-off-by: default avatarNick Hill <nhill@redhat.com>
parent 047797ef
...@@ -384,7 +384,7 @@ class EngineCoreProc(EngineCore): ...@@ -384,7 +384,7 @@ class EngineCoreProc(EngineCore):
except SystemExit: except SystemExit:
logger.debug("EngineCore exiting.") logger.debug("EngineCore exiting.")
raise
except Exception as e: except Exception as e:
if engine_core is None: if engine_core is None:
logger.exception("EngineCore failed to start.") logger.exception("EngineCore failed to start.")
......
...@@ -312,6 +312,7 @@ class BackgroundResources: ...@@ -312,6 +312,7 @@ class BackgroundResources:
def __call__(self): def __call__(self):
"""Clean up background resources.""" """Clean up background resources."""
self.engine_dead = True
for core_engine in self.core_engines: for core_engine in self.core_engines:
core_engine.close() core_engine.close()
...@@ -564,7 +565,7 @@ class SyncMPClient(MPClient): ...@@ -564,7 +565,7 @@ class SyncMPClient(MPClient):
self._send_input(EngineCoreRequestType.ADD, request) self._send_input(EngineCoreRequestType.ADD, request)
def abort_requests(self, request_ids: list[str]) -> None: def abort_requests(self, request_ids: list[str]) -> None:
if len(request_ids) > 0: if request_ids and not self.resources.engine_dead:
self._send_input(EngineCoreRequestType.ABORT, request_ids) self._send_input(EngineCoreRequestType.ABORT, request_ids)
def profile(self, is_start: bool = True) -> None: def profile(self, is_start: bool = True) -> None:
...@@ -735,7 +736,7 @@ class AsyncMPClient(MPClient): ...@@ -735,7 +736,7 @@ class AsyncMPClient(MPClient):
self._ensure_output_queue_task() self._ensure_output_queue_task()
async def abort_requests_async(self, request_ids: list[str]) -> None: async def abort_requests_async(self, request_ids: list[str]) -> None:
if len(request_ids) > 0: if request_ids and not self.resources.engine_dead:
await self._send_input(EngineCoreRequestType.ABORT, request_ids) await self._send_input(EngineCoreRequestType.ABORT, request_ids)
async def profile_async(self, is_start: bool = True) -> None: async def profile_async(self, is_start: bool = True) -> None:
...@@ -902,5 +903,6 @@ class DPAsyncMPClient(AsyncMPClient): ...@@ -902,5 +903,6 @@ class DPAsyncMPClient(AsyncMPClient):
async def _abort_requests(self, request_ids: list[str], async def _abort_requests(self, request_ids: list[str],
engine: CoreEngine) -> None: engine: CoreEngine) -> None:
await self._send_input(EngineCoreRequestType.ABORT, request_ids, if not self.resources.engine_dead:
engine) await self._send_input(EngineCoreRequestType.ABORT, request_ids,
engine)
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