From 6b3becac18e0ec1a7988bcc3a3f5eabbf700deef Mon Sep 17 00:00:00 2001 From: Alexander Olekhnovich Date: Thu, 18 Mar 2021 14:05:48 +0100 Subject: [PATCH] Properly handle fetcher pool when exiting Context manager does not seem to properly wait for the subprocesses to exit, let's join the pool manually (close need to be called before joining) --- pghoard/restore.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pghoard/restore.py b/pghoard/restore.py index 0927213e..9d549b6d 100644 --- a/pghoard/restore.py +++ b/pghoard/restore.py @@ -547,6 +547,10 @@ def fetch_all(self): with self.pool_class(processes=self._process_count()) as pool: self._queue_jobs(pool) self._wait_for_jobs_to_complete() + # Context manager does not seem to properly wait for the subprocesses to exit, let's join + # the pool manually (close need to be called before joining) + pool.close() + pool.join() break except TimeoutError: self.pending_jobs.clear()