Skip to content

Commit

Permalink
[RSDK-8684] Try with futures (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored Sep 17, 2024
1 parent e62b4d5 commit 88cb9e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/viam/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class _SingletonEventLoopThread:
_instance = None
_lock = Lock()
_ready_event = asyncio.Event()
_thread = None
_loop: Union[asyncio.AbstractEventLoop, None]
_thread: Thread

def __new__(cls):
# Ensure singleton precondition
Expand All @@ -46,7 +47,7 @@ def _run(self):
def stop(self):
if self._loop is not None:
self._loop.call_soon_threadsafe(self._loop.stop)
self._loop.close()
self._thread.join()

def get_loop(self):
if self._loop is None:
Expand Down Expand Up @@ -200,3 +201,7 @@ def setLevel(level: int):

def silence():
setLevel(FATAL + 1)


def shutdown():
logging.shutdown()
1 change: 1 addition & 0 deletions src/viam/module/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ async def stop(self):
"""Stop the module service and gRPC server"""
LOGGER.debug("Shutting down module")
try:
logging.shutdown()
if self.parent is not None:
await self.parent.close()
except Exception as e:
Expand Down

0 comments on commit 88cb9e7

Please sign in to comment.