Skip to content

Commit 68b6219

Browse files
author
David Erb
committed
fixes context exit
1 parent 0c1af43 commit 68b6219

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/chimpflow_lib/miners/context.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,22 @@ async def aenter(self) -> None:
6262
await self.server.activate()
6363

6464
# ----------------------------------------------------------------------------------------
65-
async def aexit(self, type, value, traceback) -> None:
65+
async def aexit(self, type=None, value=None, traceback=None):
6666
"""
6767
Asyncio context exit.
6868
6969
Stop service if one was started and releases any client resources.
7070
"""
7171

72+
logger.debug(f"[DISSHU] {thing_type} aexit")
73+
7274
if self.server is not None:
7375
if self.context_specification.get("start_as") == "process":
74-
# Put in request to shutdown the server.
75-
await self.server.client_shutdown()
76+
# The server associated with this context is running?
77+
if await self.is_process_alive():
78+
logger.debug(f"[DISSHU] {thing_type} calling client_shutdown")
79+
# Put in request to shutdown the server.
80+
await self.server.client_shutdown()
7681

7782
if self.context_specification.get("start_as") == "coro":
7883
await self.server.direct_shutdown()

0 commit comments

Comments
 (0)