bgc xddlZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z ddl Z Gdd Z d ed fd Z e jd d d ed fdZe jd d d ed fdZe jd d d ed fdZdS)N) TracebackType)Any)Callable) Generator)Optional)TypecreZdZdZd dZddZddZd eee d ee d ee ddfd Z dS)catch_threading_exceptionaContext 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|_dSN)args _old_hookselfs h/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/_pytest/threadexception.py__init__z"catch_threading_exception.__init__$s:> PTrthreading.ExceptHookArgsc||_dSr )r)rrs r_hookzcatch_threading_exception._hook(s  rcJtj|_|jt_|Sr ) threading excepthookrrrs r __enter__z#catch_threading_exception.__enter__+s"-#z  rexc_typeexc_valexc_tbcL|jJ|jt_d|_|`dSr )rrrr)rrrrs r__exit__z"catch_threading_exception.__exit__0s, ~)))#~  IIIr)r N)rrr N)r r ) __name__ __module__ __qualname____doc__rrrrr BaseExceptionrr rrr r s(UUUU 4 ./ -( '        rr r )NNNc #Kt5}dV|jr|jjdn|jjj}d|d}|dt j|jj|jj|jj z }tj tj |ddddS#1swxYwYdS)Nz zException in thread z )r rthreadnamejoin tracebackformat_exceptionr exc_value exc_tracebackwarningswarnpytest%PytestUnhandledThreadExceptionWarning)cm thread_namemsgs rthread_exception_runtest_hookr7<s" " $ $ M  7 M)+)?++RW^EXK::::C 277*G$G%G) C M&FsKK L L L M M M M M M M M M M M M M M M M M MsB!B??CCT) hookwrappertrylastc#2KtEd{VdSr r7r&rrpytest_runtest_setupr<L*,...........r)r8tryfirstc#2KtEd{VdSr r;r&rrpytest_runtest_callr@Qr=rc#2KtEd{VdSr r;r&rrpytest_runtest_teardownrBVr=r)rr,r0typesrtypingrrrrrr2r r7hookimplr<r@rBr&rrrFs ********Z My1A'B M M M M T4000/i(89///10/TD111/Y'78///21/TD111/+;!<///21///r