Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.11/test/support/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.11/test/support/__pycache__/threading_helper.cpython-311.opt-1.pyc

�

SԚg�����ddlZddlZddlZddlZddlZddlZddlZddlmZd�Z	d�Z
d�Zejdd���Z
dd�Zejdd���ZGd	�d
��Zdefd�Ze��Zd
d�d�ZdS)�N)�supportc�Z�tj��ttj��fS�N)�_thread�_count�len�	threading�	_dangling���:/usr/local/lib/python3.11/test/support/threading_helper.py�threading_setuprs ���>���S��!4�5�5�5�5rc�b�|\}}d}tj|d���D]7}ttj��}tj��}||krdS�8dt_tjd|d�d|�d|�d	|�dt|����
��|D]}tjd
|�����dS)Ng�?F��errorTz2threading_cleanup() failed to clean up threads in �.1fz  seconds
  before: thread count=z, dangling=z
  after: thread count=zDangling thread: )
r�sleeping_retry�listr	r
rr�environment_altered�
print_warningr)�original_values�
orig_count�orig_ndangling�timeout�_�dangling_threads�count�threads        r
�threading_cleanuprs"��!0��J���G�
�
#�G�5�
9�
9�
9���� �	� 3�4�4���� � ���J����F�F��#'�G����	K��%�	K�	K�",�	K�	K�9G�	K�	K�"'�	K�	K�47�7G�3H�3H�	K�	K�L�L�L�
#�>�>����<�&�<�<�=�=�=�=�>�>rc�F��tj����fd���}|S)z�Use this function when threads are being used.  This will
    ensure that the threads are cleaned up even when the test fails.
    c�Z��t��}	�|�t|�S#t|�wxYwr)rr)�args�key�funcs  �r
�	decoratorzreap_threads.<locals>.decorator>s<�������	$��4��;��s�#�#�#���s�#�#�#���s��*)�	functools�wraps)r$r%s` r
�reap_threadsr(:s;����_�T���$�$�$�$���$��rc#�K�|�tj}tj��}	dV�t	j��}tj|d���D]1}tj��tj��}||krdS�2t	j��|z
}d||z
�d|d�d|�d|�d	�	}t|���#t	j��}tj|d���D]0}tj��tj��}||krn9�1t	j��|z
}d||z
�d|d�d|�d|�d	�	}t|���wxYw)
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.
    NFrz!wait_threads() failed to cleanup z threads after rz seconds (count: z
, old count: �))	r�
SHORT_TIMEOUTrr�time�	monotonicr�
gc_collect�AssertionError)r�	old_count�
start_timerr�dt�msgs       r
�wait_threads_exitr4Hs��������'���� � �I�&�
�����^�%�%�
��'��u�=�=�=�
	&�
	&�A��� � � ��N�$�$�E��	�!�!����"���!�!�J�.�B�?�u�y�7H�?�?�$&�5�?�?�#�?�?�2;�?�?�?�C�!��%�%�%���^�%�%�
��'��u�=�=�=�
	&�
	&�A��� � � ��N�$�$�E��	�!�!���"���!�!�J�.�B�?�u�y�7H�?�?�$&�5�?�?�#�?�?�2;�?�?�?�C�!��%�%�%�%�%�%�%s�B<�<BEc��|�tj}|�|��|���rd|d�d�}t	|���dS)zcJoin a thread. Raise an AssertionError if the thread is still alive
    after timeout seconds.
    Nzfailed to join the thread in rz seconds)rr+�join�is_aliver/)rrr3s   r
�join_threadr8ks`�����'��
�K�K�����
�����"�C�g�C�C�C�C���S�!�!�!�"�"rc#�bK�ddl}t|��}g}		|D]+}|���|�|���,n@#tjr.t
dt|��t|��fz���xYwdV�	|r
|��tj	��}tdd��D]�}|dz
}|D]9}|�t|tj	��z
d�����:d�|D��}|sn.tjr!t
dt|��|fz����d	�|D��}|r>|�
tj��t!d
t|��z���dS#d	�|D��}|r>|�
tj��t!d
t|��z���wxYw#	|r
|��tj	��}tdd��D]�}|dz
}|D]9}|�t|tj	��z
d�����:d�|D��}|sn.tjr!t
dt|��|fz����d	�|D��}|r>|�
tj��t!d
t|��z���nQ#d	�|D��}|r>|�
tj��t!d
t|��z���wxYwwxYw)Nrz/Can't start %d threads, only %d threads started���<g{�G�z�?c�:�g|]}|����|��Sr�r7��.0�ts  r
�
<listcomp>z!start_threads.<locals>.<listcomp>�s%��>�>�>�������>�1�>�>�>rz7Unable to join %d threads during a period of %d minutesc�:�g|]}|����|��Srr>r?s  r
rBz!start_threads.<locals>.<listcomp>�s%��:�:�:�Q�Q�Z�Z�\�\�:�q�:�:�:rzUnable to join %d threads)�faulthandlerr�start�appendr�verbose�printrr,r-�ranger6�max�dump_traceback�sys�stdoutr/)�threads�unlockrD�startedrA�endtimers       r
�
start_threadsrRws����������7�m�m�G��G�Q�	��
"�
"�����	�	�	����q�!�!�!�!�
"��	���
4��G��7�|�|�S��\�\�2�3�4�4�4�����
����	Q��
�������n�&�&�G� ��B�<�<�	
B�	
B���2�
�� �B�B�A��F�F�3�w���)9�)9�9�4�@�@�A�A�A�A�>�>�g�>�>�>�����E��?�B��'�*-�g�,�,��)@�A�B�B�B��;�:�'�:�:�:�G��
Q��+�+�C�J�7�7�7�$�%@�3�w�<�<�%O�P�P�P�
Q�
Q��;�:�'�:�:�:�G��
Q��+�+�C�J�7�7�7�$�%@�3�w�<�<�%O�P�P�P�P�P�P�P��%	Q��
�������n�&�&�G� ��B�<�<�	
B�	
B���2�
�� �B�B�A��F�F�3�w���)9�)9�9�4�@�@�A�A�A�A�>�>�g�>�>�>�����E��?�B��'�*-�g�,�,��)@�A�B�B�B��;�:�'�:�:�:�G��
Q��+�+�C�J�7�7�7�$�%@�3�w�<�<�%O�P�P�P�
Q��;�:�'�:�:�:�G��
Q��+�+�C�J�7�7�7�$�%@�3�w�<�<�%O�P�P�P�P�P�P�P�P�P�P�PsF�.A	�G�	=B�G�B0F�AG�L.�B0K�A
L.�AL*�*L.c�*�eZdZdZd�Zd�Zd�Zd�ZdS)�catch_threading_exceptiona
    Context manager catching threading.Thread exception using
    threading.excepthook.

    Attributes set when an exception is caught:

    * exc_type
    * exc_value
    * exc_traceback
    * thread

    See threading.excepthook() documentation for these attributes.

    These attributes are deleted at the context manager exit.

    Usage:

        with threading_helper.catch_threading_exception() as cm:
            # code spawning a thread which raises an exception
            ...

            # check the thread exception, use cm attributes:
            # exc_type, exc_value, exc_traceback, thread
            ...

        # exc_type, exc_value, exc_traceback, thread attributes of cm no longer
        # exists at this point
        # (to avoid reference cycles)
    c�L�d|_d|_d|_d|_d|_dSr)�exc_type�	exc_value�
exc_tracebackr�	_old_hook��selfs r
�__init__z"catch_threading_exception.__init__�s*����
����!����������rc�f�|j|_|j|_|j|_|j|_dSr)rVrWrXr)r[r"s  r
�_hookzcatch_threading_exception._hook�s,���
��
�����!�/����k����rc�J�tj|_|jt_|Sr)r	�
excepthookrYr^rZs r
�	__enter__z#catch_threading_exception.__enter__�s��"�-���#�z�	���rc�8�|jt_|`|`|`|`dSr)rYr	r`rVrWrXr)r[�exc_infos  r
�__exit__z"catch_threading_exception.__exit__�s%��#�~�	���M��N����K�K�KrN)�__name__�
__module__�__qualname__�__doc__r\r^rardrrr
rTrT�sZ��������<���"�"�"����
����rrT�returnc�l�tjdkrtjjStjdkrdSdS)ayDetect whether Python can start new threads.

    Some WebAssembly platforms do not provide a working pthread
    implementation. Thread support is stubbed and any attempt
    to create a new thread fails.

    - wasm32-wasi does not have threading.
    - wasm32-emscripten can be compiled with or without pthread
      support (-s USE_PTHREADS / __EMSCRIPTEN_PTHREADS__).
    �
emscripten�wasiFT)rL�platform�_emscripten_info�pthreadsrrr
�_can_start_threadrp�s6���|�|�#�#��#�,�,�	���	�	��u��trF)�modulec�x�d}|rtstj|���dStjt|��S)z�Skip tests or modules that require working threading.

    Can be used as a function/class decorator or to skip an entire module.
    zrequires threading supportN)�can_start_thread�unittest�SkipTest�
skipUnless)rqr3s  r
�requires_working_threadingrw�sJ��
'�C�
�:��	)��#�C�(�(�(�	)�	)��"�#3�S�9�9�9rr)r�
contextlibr&rLr	r,rt�testrrrr(�contextmanagerr4r8rRrT�boolrprsrwrrr
�<module>r|si��������������
�
�
�
�������������������6�6�6�>�>�>�<�����&�&�&���&�D	"�	"�	"�	"���"Q�"Q�"Q���"Q�J6�6�6�6�6�6�6�6�r�4�����&%�$�&�&��).�
:�
:�
:�
:�
:�
:�
:r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists