bpo-43498: Fix dictionary iteration error in _ExecutorManagerThread (GH-24868)

(cherry picked from commit 7431448b81)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-11-29 04:24:08 -08:00 committed by GitHub
parent 4d2cc3ed46
commit 4b11d71185
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -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

View file

@ -0,0 +1,2 @@
Avoid a possible *"RuntimeError: dictionary changed size during iteration"*
when adjusting the process count of :class:`ProcessPoolExecutor`.