]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43498: Fix dictionary iteration error in _ExecutorManagerThread (GH-24868)
authorJakub Kulík <Kulikjak@gmail.com>
Mon, 29 Nov 2021 12:02:56 +0000 (13:02 +0100)
committerGitHub <noreply@github.com>
Mon, 29 Nov 2021 12:02:56 +0000 (14:02 +0200)
Lib/concurrent/futures/process.py
Misc/NEWS.d/next/Library/2021-04-20-14-14-16.bpo-43498.L_Hq-8.rst [new file with mode: 0644]

index 19e93a608b27690fe584ce5291d726699445cfed..695f7733305ed78db765b24e95a21837ffed5701 100644 (file)
@@ -400,7 +400,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 (file)
index 0000000..4713d14
--- /dev/null
@@ -0,0 +1,2 @@
+Avoid a possible *"RuntimeError: dictionary changed size during iteration"*
+when adjusting the process count of :class:`ProcessPoolExecutor`.