W x d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlm Z d dlm
Z
d dlZ G d d Zd
ed fdZ
ej d
d
d
ed fd Z ej d
d
d
ed fd Z ej d
d
d
ed fd ZdS ) N)
TracebackType)Any)Callable) Generator)Optional)Typec r e Zd ZdZd
dZddZddZd eee d
ee dee
ddfdZdS )catch_threading_exceptiona Context manager catching threading.Thread exception using
threading.excepthook.
Storing exc_value using a custom hook can create a reference cycle. The
reference cycle is broken explicitly when the context manager exits.
Storing thread using a custom hook can resurrect it if it is set to an
object which is being finalized. Exiting the context manager clears the
stored object.
Usage:
with threading_helper.catch_threading_exception() as cm:
# code spawning a thread which raises an exception
...
# check the thread exception: use cm.args
...
# cm.args attribute no longer exists at this point
# (to break a reference cycle)
returnNc " d | _ d | _ d S N)args _old_hookselfs i/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/_pytest/threadexception.py__init__z"catch_threading_exception.__init__$ s :> PT r threading.ExceptHookArgsc || _ d S r
)r )r r s r _hookzcatch_threading_exception._hook( s
r c J t j | _ | j t _ | S r
) threading
excepthookr r r s r __enter__z#catch_threading_exception.__enter__+ s "-#z r exc_typeexc_valexc_tbc L | j J | j t _ d | _ | `d S r
)r r r r )r r r r s r __exit__z"catch_threading_exception.__exit__0 s, ~)))#~ IIIr )r N)r r r N)r r
)__name__
__module____qualname____doc__r r r r r
BaseExceptionr r r r r
r
s (U U U U
4
./ -( '
r r
r )NNNc # K t 5 } d V | j r| j j dn| j j j }d| d}|d t j | j j | j j | j j z
}t j t j
| d d d d S # 1 swxY w Y d S )Nz