Skip to content

Commit

Permalink
fixes context exit
Browse files Browse the repository at this point in the history
  • Loading branch information
David Erb committed Jun 8, 2023
1 parent 0c1af43 commit 68b6219
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/chimpflow_lib/miners/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ async def aenter(self) -> None:
await self.server.activate()

# ----------------------------------------------------------------------------------------
async def aexit(self, type, value, traceback) -> None:
async def aexit(self, type=None, value=None, traceback=None):
"""
Asyncio context exit.
Stop service if one was started and releases any client resources.
"""

logger.debug(f"[DISSHU] {thing_type} aexit")

if self.server is not None:
if self.context_specification.get("start_as") == "process":
# Put in request to shutdown the server.
await self.server.client_shutdown()
# The server associated with this context is running?
if await self.is_process_alive():
logger.debug(f"[DISSHU] {thing_type} calling client_shutdown")
# Put in request to shutdown the server.
await self.server.client_shutdown()

if self.context_specification.get("start_as") == "coro":
await self.server.direct_shutdown()
Expand Down

0 comments on commit 68b6219

Please sign in to comment.