Skip to content

Commit 72190cd

Browse files
author
David Erb
committed
fixes context exit
1 parent 019b252 commit 72190cd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/echolocator_lib/guis/context.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,21 @@ async def aenter(self):
3838
await self.server.start_process()
3939

4040
# ----------------------------------------------------------------------------------------
41-
async def aexit(self, type, value, traceback):
42-
""" """
41+
async def aexit(self, type=None, value=None, traceback=None):
42+
"""
43+
Asyncio context exit.
44+
45+
Stop service if one was started and releases any client resources.
46+
"""
4347
logger.debug(f"[DISSHU] {thing_type} aexit")
4448

4549
if self.server is not None:
4650
if self.context_specification.get("start_as") == "process":
47-
logger.debug(f"[DISSHU] {thing_type} calling client_shutdown")
48-
# Put in request to shutdown the server.
49-
await self.server.client_shutdown()
51+
# The server associated with this context is running?
52+
if await self.is_process_alive():
53+
logger.debug(f"[DISSHU] {thing_type} calling client_shutdown")
54+
# Put in request to shutdown the server.
55+
await self.server.client_shutdown()
5056

5157
if self.context_specification.get("start_as") == "coro":
5258
await self.server.direct_shutdown()

0 commit comments

Comments
 (0)