Sindbad~EG File Manager
�
(Μgq����ddlZddlZddlZddlZddlZddlZddlZddlmZd�Z d�Z
d�Zejdd��Z
dd�Zejdd��ZGd �d
�Zdefd�Ze�Zd
d�d�Zy)�N)�supportc�\�tj�ttj�fS�N)�_thread�_count�len� threading� _dangling���:/usr/local/lib/python3.12/test/support/threading_helper.py�threading_setuprs���>�>��S��!4�!4�5�5�5rc�b�|\}}d}tj|d��D]6}ttj�}tj�}||ks�6ydt_tjd|d�d|�d|�d �dt���
�|D]}tjd
|����y)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�� � � 3� 3�4����� ���J���:�#'�G�������c�]�"�",��[��8H�I!�!&��{�3�7G�3H�2I� K�L�
#����� 1�&��<�=�#rc�B��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�N��t�} �|�t|�S#t|�wxYwr)rr)�args�key�funcs �r
� decoratorzreap_threads.<locals>.decorator>s)������ $���;��s�#���s�#�s��
$)� functools�wraps)r$r%s` r
�reap_threadsr(:s(����_�_�T��$��$��rc#�K�|�tj}tj�} d��t j
�}tj|d��D]1}tj�tj�}||ks�1yt j
�|z
}d|z
�d|d�d|�d|�d � }t|��#t j
�}tj|d��D]1}tj�tj�}||ks�1wt j
�|z
}d|z
�d|d�d|�d|�d � }t|��xYw�w)
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_exitr4Hsa�������'�'����� �I�&�
��^�^�%�
��'�'��u�=�A���� ��N�N�$�E�� �!�� >����!�J�.�B�6�u�y�7H�6I�J$�$&�s�8�,�#�W�M�)��A�?�C�!��%�%���^�^�%�
��'�'��u�=�A���� ��N�N�$�E�� �!�� >����!�J�.�B�6�u�y�7H�6I�J$�$&�s�8�,�#�W�M�)��A�?�C�!��%�%�s)�'E�C�AE�
8E�AE�8E�Ec��|�tj}|j|�|j�rd|d�d�}t |��y)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_threadr8ksJ�����'�'��
�K�K���
����-�g�c�]�(�C���S�!�!�rc#�8K� ddl}t|�}g} |D]#}|j�|j |��% d�� |r|�tj�}tdd�D]�}|dz
}|D]2}|jt|tj�z
d���4|D�cgc]}|j�s�|��}}|sn,t
js�ttdt|�|fz���|D�cgc]}|j�s�|��}}|r8|�|jt j"�t%dt|�z��y#t$rd}Y��^wxYw#t
jr"tdt|�t|�fz��xYwcc}wcc}w#|D�cgc]}|j�s�|��ncc}w}}|r8|�|jt j"�t%dt|�z��wxYw# |r|�tj�}tdd�D]�}|dz
}|D]2}|jt|tj�z
d���4|D�cgc]}|j�s�|��ncc}w}}|sn,t
js�ztdt|�|fz���|D�cgc]}|j�s�|��ncc}w}}|r8|�|jt j"�t%dt|�z��w#|D�cgc]}|j�s�|��ncc}w}}|r8|�|jt j"�t%dt|�z��wxYwxYw�w) Nrz/Can't start %d threads, only %d threads started���<g{�G�z�?z7Unable to join %d threads during a period of %d minuteszUnable to join %d threads)�faulthandler�ImportErrorr�start�appendr�verbose�printrr,r-�ranger6�maxr7�dump_traceback�sys�stdoutr/)�threads�unlockr=�started�t�endtimers r
�
start_threadsrMws?�������7�m�G��G�Q� ������ ����q�!�� � Q�����n�n�&�G� ��B�<���2�
�� �A��F�F�3�w����)9�9�4�@�A�!�&-�>�g������1�g��>����?�?��'�*-�g�,��)@�A�B�(�#*�:�'�Q�Q�Z�Z�\�q�'�G�:���+� �/�/��
�
�;�$�%@�3�w�<�%O�P�P���C������ �����G��7�|�S��\�2�3�4���?��;��'�:�'�Q�Q�Z�Z�\�q�'��:�G�:���+� �/�/��
�
�;�$�%@�3�w�<�%O�P�P���! Q�����n�n�&�G� ��B�<���2�
�� �A��F�F�3�w����)9�9�4�@�A�!�&-�>�g������1�g��>��>����?�?��'�*-�g�,��)@�A�B�(�#*�:�'�Q�Q�Z�Z�\�q�'��:�G�:���+� �/�/��
�
�;�$�%@�3�w�<�%O�P�P���#*�:�'�Q�Q�Z�Z�\�q�'��:�G�:���+� �/�/��
�
�;�$�%@�3�w�<�%O�P�P��s�N�E�
N�(E*�H�A,F,�1F"�F"�F,�"F,�=N�F'�F'�=N�E'�#N�&E'�'N�*5F�H�"F,�'N�,H�1G�G�AH�N�N�A,L2�?J
�J
�L2�6L2�N�K0�+K0�/AN�2N�7M�
M�AN�N�Nc�(�eZdZdZd�Zd�Zd�Zd�Zy)�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�J�d|_d|_d|_d|_d|_yr)�exc_type� exc_value�
exc_tracebackr� _old_hook��selfs r
�__init__z"catch_threading_exception.__init__�s&����
����!��������rc��|j|_|j|_|j|_|j|_yr)rQrRrSr)rVr"s r
�_hookzcatch_threading_exception._hook�s1���
�
��
������!�/�/����k�k��rc�Z�tj|_|jt_|Sr)r �
excepthookrTrYrUs r
� __enter__z#catch_threading_exception.__enter__�s ��"�-�-���#�z�z� ���rc�>�|jt_|`|`|`|`yr)rTr r[rQrRrSr)rV�exc_infos r
�__exit__z"catch_threading_exception.__exit__�s#��#�~�~� ���M��N����KrN)�__name__�
__module__�__qualname__�__doc__rWrYr\r_rrr
rOrO�s���<�"��
rrO�returnc��tjdk(rtjjStjdk(ryy)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)rF�platform�_emscripten_info�pthreadsrrr
�_can_start_threadrk�s6���|�|�|�#��#�#�,�,�,� ���� ��rF)�modulec�v�d}|rtstj|��ytjt|�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)rlr3s r
�requires_working_threadingrr�s;��
'�C�
���#�#�C�(�(� ��"�"�#3�S�9�9rr)r�
contextlibr&rFr r,ro�testrrrr(�contextmanagerr4r8rMrO�boolrkrnrrrrr
�<module>rws������
�����6�>�<����&��&�D "����'Q��'Q�T6�6�r�4��&%�&��).�
:r
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists