/usr/lib/python3.10/test/support/__pycache__
Edit: /usr/lib/python3.10/test/support/__pycache__/threading_helper.cpython-310.pyc (6323B)
o
9j @ s d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ dd Zdd Z dd Z
ejdd d
ZdddZ
ejdd
dZG dd dZdS ) N)supportc C s t tj fS N)_thread_count threading _danglingcopy r r 4/usr/lib/python3.10/test/support/threading_helper.pythreading_setup s r c
G s d}t |D ]L}t tjf}|| kr d S |sGdt_|d }td|d | d d|d dt| d |D ]
}td | q:d }d }t
d
t qd S )Nd T z&threading_cleanup() failed to cleanup r z threads (count: z, dangling: )zDangling thread: {Gz?)ranger r r r r environment_altered
print_warninglentimesleep
gc_collect)original_values
_MAX_COUNTcountvaluesdangling_threadsthreadr r r
threading_cleanup s,
r c s t fdd}|S )zUse this function when threads are being used. This will
ensure that the threads are cleaned up even when the test fails.
c s$ t }z | W t| S t| w r )r r )argskeyfuncr r
decorator: s zreap_threads.
.decorator) functoolswraps)r! r" r r r
reap_threads6 s r% c c s | du rt j} t }zCdV W t }|| } t }||kr$dS t |krFt | }d|| d|dd| d| d }t|td t qt }|| } t }||krc w t |krt | }d|| d|dd| d| d }t|td t qY)
aH
bpo-31234: Context manager to wait until all threads created in the with
statement exit.
Use _thread.count() to check if threads exited. Indirectly, wait until
threads exit the internal t_bootstrap() C function of the _thread module.
threading_setup() and threading_cleanup() are designed to emit a warning
if a test leaves running threads in the background. This context manager
is designed to cleanup threads started by the _thread.start_new_thread()
which doesn't allow to wait for thread exit, whereas thread.Thread has a
join() method.
NTz!wait_threads() failed to cleanup z threads after .1fz seconds (count: z
, old count: r r ) r
SHORT_TIMEOUTr r r monotonicAssertionErrorr r )timeout old_count
start_timedeadliner dtmsgr r r
wait_threads_exitD sZ
r0 c C s: |du rt j}| | | rd|dd}t|dS )zcJoin a thread. Raise an AssertionError if the thread is still alive
after timeout seconds.
Nzfailed to join the thread in r&