Skip to content

bpo-40275: Fix test.support.threading_helper #20488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Lib/test/support/threading_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _thread
import contextlib
import functools
import _thread
import sys
import threading
import time

Expand Down Expand Up @@ -47,7 +48,7 @@ def threading_cleanup(*original_values):
values = None

time.sleep(0.01)
gc_collect()
support.gc_collect()


def reap_threads(func):
Expand Down Expand Up @@ -98,7 +99,7 @@ def wait_threads_exit(timeout=None):
f"(count: {count}, old count: {old_count})")
raise AssertionError(msg)
time.sleep(0.010)
gc_collect()
support.gc_collect()


def join_thread(thread, timeout=None):
Expand All @@ -124,7 +125,7 @@ def start_threads(threads, unlock=None):
t.start()
started.append(t)
except:
if verbose:
if support.verbose:
print("Can't start %d threads, only %d threads started" %
(len(threads), len(started)))
raise
Expand All @@ -133,15 +134,15 @@ def start_threads(threads, unlock=None):
try:
if unlock:
unlock()
endtime = starttime = time.monotonic()
endtime = time.monotonic()
for timeout in range(1, 16):
endtime += 60
for t in started:
t.join(max(endtime - time.monotonic(), 0.01))
started = [t for t in started if t.is_alive()]
if not started:
break
if verbose:
if support.verbose:
print('Unable to join %d threads during a period of '
'%d minutes' % (len(started), timeout))
finally:
Expand Down