Skip to content

Commit 9c3cc31

Browse files
author
David Erb
committed
fixes context exit
1 parent 139969d commit 9c3cc31

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/xchembku_lib/datafaces/context.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ async def aenter(self):
4646
await self.server.start_process()
4747

4848
# ----------------------------------------------------------------------------------------
49-
async def aexit(self, type, value, traceback):
50-
""" """
49+
async def aexit(self, type=None, value=None, traceback=None):
50+
"""
51+
Asyncio context exit.
52+
53+
Stop service if one was started and releases any client resources.
54+
"""
55+
logger.debug(f"[DISSHU] {thing_type} aexit")
5156

5257
if self.server is not None:
5358
if self.context_specification.get("start_as") == "process":
54-
# Put in request to shutdown the server.
55-
await self.server.client_shutdown()
59+
# The server associated with this context is running?
60+
if await self.is_process_alive():
61+
logger.debug(f"[DISSHU] {thing_type} calling client_shutdown")
62+
# Put in request to shutdown the server.
63+
await self.server.client_shutdown()
5664

5765
if self.context_specification.get("start_as") == "coro":
5866
await self.server.direct_shutdown()

0 commit comments

Comments
 (0)