
    CNh                        d Z ddlZddlmZ ddlmZ ddlmZ g dZeddgz  Zej                  j                  d	      Zej                         Zdaej                  j                  d	 e       d
efdef       da G d d      Zdad Zd ZeZy)z=Implements the standard threading module, using greenthreads.    N)thread)time)	greenlets)
_start_new_thread_allocate_lock_sleeplocal
stack_sizeLockcurrentThreadcurrent_thread_after_fork	_shutdown	get_ident_set_sentinel	threading_threadr      c                       e Zd ZdZd Zd ZddZd ZeZd Z	e	Z
 eee	      Z ed       Zd	 ZeZ ed
       Zd ZeZy)_GreenThreadzQWrapper for GreenThread objects to provide Thread-like attributes
    and methodsc                 @    || _         dt        z  | _        t        dz  ay )NzGreenThread-%dr   )_g_count_name)selfgs     :/usr/lib/python3/dist-packages/eventlet/green/threading.py__init__z_GreenThread.__init__    s    %.
!    c                 <    d| j                   d| j                  dS )Nz<_GreenThread(z, z)>)r   r   r   s    r   __repr__z_GreenThread.__repr__&   s    +/::tww??r   Nc                 6    | j                   j                         S N)r   wait)r   timeouts     r   joinz_GreenThread.join)   s    ww||~r   c                     | j                   S r$   )r   r!   s    r   getNamez_GreenThread.getName,   s    zzr   c                 $    t        |      | _        y r$   )strr   )r   names     r   setNamez_GreenThread.setName0   s    Y
r   c                 ,    t        | j                        S r$   )idr   r!   s    r   <lambda>z_GreenThread.<lambda>6   s    "TWW+ r   c                      yNT r!   s    r   isAlivez_GreenThread.isAlive8   s    r   c                      yr2   r3   r!   s    r   r0   z_GreenThread.<lambda><   s    r   c                     | j                   S r$   )daemonr!   s    r   isDaemonz_GreenThread.isDaemon>   s    {{r   r$   )__name__
__module____qualname____doc__r   r"   r'   r)   get_namer-   set_namepropertyr,   identr4   is_aliver7   r8   	is_daemonr3   r   r   r   r      sa    @HHGW%D-.EH'(FIr   r   c                     t         st        d      a t        t         j                  d      rt        | d      s| j                  | _        | S )Nr   r=   )__threading
__import__hasattrThreadr)   r=   )ts    r   _fixup_threadrI   F   s;      -""J/:&YY
Hr   c                     t        j                         } | st        t        j	                               S 	 t
        j                  t        |       j                        }||S t        2t        j                  j                  t        d      j                        a
t               D cg c]  }|j                   k(  s| }}|r|d   S fd}	 | j#                  |       t%        |       x}<   |S # t        $ r i xt
        _        Y w xY wc c}w # t        $ r! t        t        j	                               }Y |S w xY w)Nr   r   c                     = y r$   r3   )r   activeg_ids    r   cleanupzcurrent_thread.<locals>.cleanupt   s
    4Lr   )greenlet
getcurrentrI   __orig_threadingr   __threadlocalrL   AttributeErrorr/   get__patched_enumerateeventletpatcherpatch_functionrE   	enumerater@   linkr   )r   rH   thfoundrN   rL   rM   s        @@r   r   r   W   s3   A-<<>??+%% a5D

4A} "&..==j>U>_>_`-/DB288t3CRDEDQx+	w (?*F4LHA  +(**%+ E  = *99;< H=s/   C7 +D DD 7DD&EE)r<   rV   eventlet.greenr   r   eventlet.supportr   rO   __patched__rW   originalrQ   r	   rR   rU   injectglobalsr   r   rD   rI   r   r   r3   r   r   <module>rc      s    C  !  2= _- -##,,[9  &&(  	    ITN	 
$ $N ")X r   