From 430956b6b598350df9763e3d1a82db910cfd1a2e Mon Sep 17 00:00:00 2001 From: James Douglass Date: Thu, 10 Oct 2024 13:04:36 -0700 Subject: [PATCH] Attempting to shut down the work queue early. RE:#360 --- src/pygeoprocessing/geoprocessing.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pygeoprocessing/geoprocessing.py b/src/pygeoprocessing/geoprocessing.py index c539f260..3bed89e0 100644 --- a/src/pygeoprocessing/geoprocessing.py +++ b/src/pygeoprocessing/geoprocessing.py @@ -3299,6 +3299,13 @@ def _fill_work_queue(): worker.join(max_timeout) break except queue.Empty: + # Shut down the worker thread. + # The work queue only has 10 items in it at a time, so it's pretty + # likely that we can preemptively shut it down by adding a ``None`` + # here and then have the queue not take too much longer to quit. + work_queue.put(None) + + # Close thread-local raster objects signal_raster = signal_band = None target_raster = target_band = None mask_raster = mask_band = None