
    h                     2    d Z ddlZddlmZ  G d de      Zy)z^
The implementation of thread patching for Python versions
prior to 3.13.

Internal use only.
    N   )BasePatcherc                       e Zd Zd Zd Zy)Patcherc                     ddl m} | j                  }|j                  j	                         D ]%  }| |       k(  r| j                  |d |      |_        ' y )Nr   )main_native_thread)gevent.threadingr   threading_mod_activevalues(_make_existing_non_main_thread_join_funcjoin)selfr   r
   threads       [/var/www/html/engine/venv/lib/python3.12/site-packages/gevent/monkey/_patch_thread_lt313.pypatch_active_threadszPatcher.patch_active_threads   sW    7**#++224 	eF+--GGPTVcdFK	e    c                 Z   dd l }ddlm | j                  | j                  | j
                  |j                         x_        j                  _	        j                  J j                         _        j                  j                          fd} d|       y )Nr   r   )
patch_itemc                  >   j                   sy j                   j                          ddlm}  	  |         d_        j                  _         d _	                  d       y #  ddlm}   |       j
                  gt        j                           Y exY w)Nr   )sleep)get_hubF	_shutdown)
_tstate_lockreleasegeventr   r   print_exceptionsysexc_info_is_stopped_gevent_real_tstate_lock)r   r   	_greenletmain_threadorig_shutdownr   r
   s     r   r   zVPatcher.patch_threading_shutdown_on_main_thread_not_already_patched.<locals>._shutdown/   s     ++$$,,.$F ',K#'2'K'KK$37K0
 O}k=A'F ,)	)))EcllnEs   A( (2Br   )greenletapir   r
   r#   r$   
getcurrentr"   r   r!   Lockacquire)r   r%   r   r"   r#   r$   r   r
   s      @@@@@r   ;patch_threading_shutdown_on_main_thread_not_already_patchedzCPatcher.patch_threading_shutdown_on_main_thread_not_already_patched   s    #**&&**,4,?,?,AA	K)/:/G/G,33??? $1#5#5#7   ((*	B 	B> 	=+y9r   N)__name__
__module____qualname__r   r*    r   r   r   r      s    e5:r   r   )__doc__r   _patch_thread_commonr   r   r.   r   r   <module>r1      s"     .@:k @:r   