-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
After enabling tracemalloc.start(), the first call to InterpreterPoolExecutor.submit() works, but the second one hangs.
It hangs on this line at threading.py:939:
self._os_thread_handle = _ThreadHandle()This code reproduces the problem:
import concurrent.futures
import tracemalloc
# Set this to True to reproduce the hang below
enableTracemalloc = False
print(f"{enableTracemalloc=}")
if enableTracemalloc:
tracemalloc.start()
with concurrent.futures.InterpreterPoolExecutor() as executor:
futures = []
for id in range(1, 3):
print(f"Submitting {id=} {enableTracemalloc=}")
# The second call to this hangs if tracemalloc.start() has been called
futures.append(executor.submit(lambda x: x, x=id))
print(f"Submitted {id=} {enableTracemalloc=}")
results = [
future.result()
for future in concurrent.futures.as_completed(futures)
]
print(f"{results=}")When tracemalloc is disabled it works:
enableTracemalloc=False
Submitting id=1 enableTracemalloc=False
Submitted id=1 enableTracemalloc=False
Submitting id=2 enableTracemalloc=False
Submitted id=2 enableTracemalloc=False
results=[1, 2]
When tracemalloc is enabled it hangs:
enableTracemalloc=True
Submitting id=1 enableTracemalloc=True
Submitted id=1 enableTracemalloc=True
Submitting id=2 enableTracemalloc=True
<hangs forever>
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error