Predictor.shutdown: use join() instead of terminate()

This commit is contained in:
Robert Sachunsky 2026-05-19 03:16:15 +02:00
parent ffe5cdc519
commit 9efce5e9f2

View file

@ -194,17 +194,18 @@ class Predictor(mp.context.SpawnProcess):
def shutdown(self): def shutdown(self):
# do not terminate from forked processor instances # do not terminate from forked processor instances
if mp.parent_process() is None: if not hasattr(self, 'model'):
self.stopped.set() self.stopped.set()
self.join()
self.taskq.close() self.taskq.close()
self.taskq.cancel_join_thread() self.taskq.cancel_join_thread()
self.resultq.close() self.resultq.close()
self.resultq.cancel_join_thread() self.resultq.cancel_join_thread()
self.logq.close() self.logq.close()
self.terminate() #self.terminate()
else: else:
del self.model del self.model
def __del__(self): def __del__(self):
#self.logger.debug(f"deinit of {self} in {mp.current_process().name}") #self.logger.debug(f"deinit of {self.name} in {mp.current_process().name}")
self.shutdown() self.shutdown()