From 62cee527070d50efb89c716a40e67c93b485175d Mon Sep 17 00:00:00 2001 From: Myungjin Lee Date: Fri, 24 May 2024 18:15:07 -0700 Subject: [PATCH] misc: explicit exit (#6) Ensure the termination of main thread by explicitly calling os._exit(0). --- multiworld/world_manager.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/multiworld/world_manager.py b/multiworld/world_manager.py index acdb44e..c23eeb0 100644 --- a/multiworld/world_manager.py +++ b/multiworld/world_manager.py @@ -69,12 +69,13 @@ def __init__(self, enable_monitor=True): _ = asyncio.create_task(self._cleanup_worlds()) def cleanup(self): - """Call exit(0) explicitly.""" + """Call os._exit(0) explicitly.""" # TODO: This is a temporary workaround to prevent main thread hang - # even after it's done. Calling exit(0) guarantees termination - # of the process. We need to figure out why sometimes it's not - # terminated without explicit call of exit(). - exit(0) + # even after it's done. Calling os._exit(0) guarantees + # terminationof the process. We need to figure out why + # sometimes it's not terminated without explicit call of + # os._exit(0). + os._exit(0) async def _cleanup_worlds(self): logger.debug("starting _cleanup_worlds task")