Skip to content

Commit 0367d2d

Browse files
committed
pythongh-111644: Enhance support threading_cleanup()
Copy the list of dangling thread to provide a consistent output between the warning and the "Dangling thread" listing.
1 parent f21b230 commit 0367d2d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Lib/test/support/threading_helper.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,23 @@ def threading_cleanup(*original_values):
3636
if not count:
3737
# Display a warning at the first iteration
3838
support.environment_altered = True
39-
dangling_threads = values[1]
39+
40+
# Copy the thread list to get a consistent output between the
41+
# warning and the "Dangling thread" listing.
42+
dangling_threads = list(values[1])
43+
4044
support.print_warning(f"threading_cleanup() failed to cleanup "
4145
f"{values[0] - original_values[0]} threads "
4246
f"(count: {values[0]}, "
4347
f"dangling: {len(dangling_threads)})")
4448
for thread in dangling_threads:
4549
support.print_warning(f"Dangling thread: {thread!r}")
50+
breakpoint()
4651

47-
# Don't hold references to threads
52+
# Break any potential reference cycle
4853
dangling_threads = None
54+
55+
# Break any potential reference cycle
4956
values = None
5057

5158
time.sleep(0.01)

0 commit comments

Comments
 (0)