
    in                     F    d Z ddlZddlmZ ddlmZ  G d de          ZdS )z^
The implementation of thread patching for Python versions
prior to 3.13.

Internal use only.
    N)LoopExit   )BasePatcherc                       e Zd Zd Zd ZdS )Patcherc                     ddl m} | j        }|j                                        D ]-}| |            k    r|                     |d |          |_        .d S )Nr   )main_native_thread)gevent.threadingr	   threading_mod_activevalues(_make_existing_non_main_thread_join_funcjoin)selfr	   r   threads       L/usr/local/lib/python3.11/dist-packages/gevent/monkey/_patch_thread_lt313.pypatch_active_threadszPatcher.patch_active_threads   s}    777777*#+2244 	e 	eF++----GGPTVcddFKK	e 	e    c                 >   dd l }ddlm | j        | j        | j        |                                x_        j        _	        j	        J 
                                _        j                                         fd} d|           d S )Nr   r   )
patch_itemc                  ^   j         sd S j                                          ddlm}  	  |              n4#  ddlm}   |            j        gt          j                    R   Y nxY wd_        j	        _         d _	        	               n# t          $ r Y nw xY w d           d S )Nr   )sleep)get_hubF	_shutdown)_tstate_lockreleasegeventr   r   print_exceptionsysexc_info_is_stopped_gevent_real_tstate_lockr   )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F ,+++++)		))EclnnEEEEEE ',K#'2'KK$37K0
   J}k=AAAAAs   
6 /A'
B 
BB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A	K)/:/G,3??? $1#5#5#7#7  ((*** 	B  	B  	B  	B  	B  	B  	B  	B  	BD 	
=+y99999r   N)__name__
__module____qualname__r   r+    r   r   r   r      s5        e e e8: 8: 8: 8: 8:r   r   )__doc__r   gevent.exceptionsr   _patch_thread_commonr   r   r/   r   r   <module>r3      s|     


 & & & & & & - - - - - -C: C: C: C: C:k C: C: C: C: C:r   