Skip to content

Commit 88cb9e7

Browse files
authored
[RSDK-8684] Try with futures (#733)
1 parent e62b4d5 commit 88cb9e7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/viam/logging.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class _SingletonEventLoopThread:
2424
_instance = None
2525
_lock = Lock()
2626
_ready_event = asyncio.Event()
27-
_thread = None
27+
_loop: Union[asyncio.AbstractEventLoop, None]
28+
_thread: Thread
2829

2930
def __new__(cls):
3031
# Ensure singleton precondition
@@ -46,7 +47,7 @@ def _run(self):
4647
def stop(self):
4748
if self._loop is not None:
4849
self._loop.call_soon_threadsafe(self._loop.stop)
49-
self._loop.close()
50+
self._thread.join()
5051

5152
def get_loop(self):
5253
if self._loop is None:
@@ -200,3 +201,7 @@ def setLevel(level: int):
200201

201202
def silence():
202203
setLevel(FATAL + 1)
204+
205+
206+
def shutdown():
207+
logging.shutdown()

src/viam/module/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ async def stop(self):
160160
"""Stop the module service and gRPC server"""
161161
LOGGER.debug("Shutting down module")
162162
try:
163+
logging.shutdown()
163164
if self.parent is not None:
164165
await self.parent.close()
165166
except Exception as e:

0 commit comments

Comments
 (0)