diff --git a/src/terrain_management/large_scale_terrain/high_resolution_DEM_generator.py b/src/terrain_management/large_scale_terrain/high_resolution_DEM_generator.py index f7264b4..6ab9bb3 100644 --- a/src/terrain_management/large_scale_terrain/high_resolution_DEM_generator.py +++ b/src/terrain_management/large_scale_terrain/high_resolution_DEM_generator.py @@ -13,6 +13,7 @@ import logging import time import copy +import sys from src.terrain_management.large_scale_terrain.utils import ScopedTimer, BoundingBox, CraterMetadata from src.terrain_management.large_scale_terrain.crater_generation import ( @@ -593,8 +594,13 @@ def update_high_res_dem(self, coords: Tuple[float, float]) -> bool: # Threaded update, the function will return before the update is done thread = threading.Thread(target=self.threaded_high_res_dem_update) thread.start() + thread.join() self.sim_is_warm = True updated = True + if not self.monitor_thread.thread.is_alive(): + logger.warn("Simulation exited before being fully initialized. Trying to exit.") + logger.warn("You may need to kill the process manually. Or use Ctrl + \ to exit.") + sys.exit(0) # Map update if the block has changed if self.current_block_coord != block_coordinates: diff --git a/src/terrain_management/large_scale_terrain/high_resolution_DEM_workers.py b/src/terrain_management/large_scale_terrain/high_resolution_DEM_workers.py index 03d1dd9..25d45f4 100644 --- a/src/terrain_management/large_scale_terrain/high_resolution_DEM_workers.py +++ b/src/terrain_management/large_scale_terrain/high_resolution_DEM_workers.py @@ -280,6 +280,11 @@ def shutdown(self) -> None: while not self.input_queue.empty(): self.input_queue.get() logger.debug("Worker input queue emptied.") + try: + while True: + self.input_queue.task_done() + except: + pass self.input_queue.join() logger.debug("Worker input queue joined.") @@ -522,6 +527,11 @@ def shutdown(self) -> None: while not self.input_queue.empty(): self.input_queue.get() self.input_queue.task_done() + try: + while True: + self.input_queue.task_done() + except: + pass logger.debug("Emptied input queue.") self.input_queue.join() logger.debug("Joined input queue.")