From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 29 Nov 2021 12:28:46 +0000 (-0800) Subject: bpo-43498: Fix dictionary iteration error in _ExecutorManagerThread (GH-24868) X-Git-Tag: v3.9.10~95 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b9d886567c4fc6279c2198b6711f0590dbf3336;p=thirdparty%2FPython%2Fcpython.git bpo-43498: Fix dictionary iteration error in _ExecutorManagerThread (GH-24868) (cherry picked from commit 7431448b817d3bf87f71661cf8f3d537807ab2e2) Co-authored-by: Jakub KulĂ­k --- diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 90bc98bf2ecd..a29e5247ab85 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -373,7 +373,7 @@ class _ExecutorManagerThread(threading.Thread): assert not self.thread_wakeup._closed wakeup_reader = self.thread_wakeup._reader readers = [result_reader, wakeup_reader] - worker_sentinels = [p.sentinel for p in self.processes.values()] + worker_sentinels = [p.sentinel for p in list(self.processes.values())] ready = mp.connection.wait(readers + worker_sentinels) cause = None diff --git a/Misc/NEWS.d/next/Library/2021-04-20-14-14-16.bpo-43498.L_Hq-8.rst b/Misc/NEWS.d/next/Library/2021-04-20-14-14-16.bpo-43498.L_Hq-8.rst new file mode 100644 index 000000000000..4713d1427ccd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-04-20-14-14-16.bpo-43498.L_Hq-8.rst @@ -0,0 +1,2 @@ +Avoid a possible *"RuntimeError: dictionary changed size during iteration"* +when adjusting the process count of :class:`ProcessPoolExecutor`.