bpo-43498: Fix dictionary iteration error in _ExecutorManagerThread (GH-24868)
![](https://secure.gravatar.com/avatar/cc7737cd64a84f1b5c61a160798e97ee.jpg?s=120&d=mm&r=g)
https://github.com/python/cpython/commit/4b11d7118561a12322d3cfa76c5941690b2... commit: 4b11d7118561a12322d3cfa76c5941690b241149 branch: 3.10 author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> committer: miss-islington <31488909+miss-islington@users.noreply.github.com> date: 2021-11-29T04:24:08-08:00 summary: bpo-43498: Fix dictionary iteration error in _ExecutorManagerThread (GH-24868) (cherry picked from commit 7431448b817d3bf87f71661cf8f3d537807ab2e2) Co-authored-by: Jakub KulĂk <Kulikjak@gmail.com> files: A Misc/NEWS.d/next/Library/2021-04-20-14-14-16.bpo-43498.L_Hq-8.rst M Lib/concurrent/futures/process.py diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 764719859f7ce..6ee2ce626e456 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -373,7 +373,7 @@ def wait_result_broken_or_wakeup(self): 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 0000000000000..4713d1427ccd3 --- /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`.
participants (1)
-
miss-islington