Brian Quinlan <br...@sweetapp.com> added the comment: Great report Steven!
I was able to reproduce this with the attached patch (just adds some sleeps and prints) and this script: from threading import current_thread from concurrent.futures import ThreadPoolExecutor from time import sleep pool = ThreadPoolExecutor(100) def f(): print("I'm running in: ", current_thread().name) def g(): print("I'm running in: ", current_thread().name) for _ in range(100): pool.submit(f) sleep(0.1) pool.submit(g) sleep(1.5) The output for me was: 👶 Creating new thread: ThreadPoolExecutor-0_0 I'm running in: ThreadPoolExecutor-0_0 Setting _shutdown 💀 Killing 1 workers 💀 👶 Creating new thread: ThreadPoolExecutor-0_1 I'm running in: ThreadPoolExecutor-0_1 So another thread was created *after* shutdown. It seems like the most obvious way to fix this is by adding a lock for the global _shutdown variable. ---------- keywords: +patch Added file: https://bugs.python.org/file48311/find-race.diff _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31783> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com