
    <|hZ)                        d Z ddlZg dej                  dd dk\  rg dng z   ZdgZddlZdZeg d	z  Zej                  d
        e	ed      rej                  d       ej                  Z
ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  e	ed      rej                  d       d&dZd'dZd'dZ d(dZ! G d d      Z"d Z# G d d e      Z$e$xZ%Z&d! Z' e	ed"      rejP                  Z)d&d#Z(nejU                  d"        ee e+       ed$      Zeez   Z,e,jU                  d%       y))aK  
Implementation of the standard :mod:`thread` module that spawns greenlets.

.. note::

    This module is a helper for :mod:`gevent.monkey` and is not
    intended to be used directly. For spawning greenlets in your
    applications, prefer higher level constructs like
    :class:`gevent.Greenlet` class or :func:`gevent.spawn`.
    N)allocate_lock	get_identexitLockType
stack_sizestart_new_thread_local   )      )start_joinable_threadlock_ThreadHandle_make_thread_handleerror_thread)TIMEOUT_MAXallocateexit_threadinterrupt_main	start_newget_native_iddaemon_threads_allowed)PYPY)copy_globals)
getcurrentGreenletExit)sleep)get_hub_if_exists)Greenlet)BoundedSemaphore)local)LoopExitRLockc                 0    | 
t               } t        |       S N)r   id)grs    L/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/thread.pyr   r   J   s    	z\b6M    c                 l    |t        j                  | g|i |}|S t        j                  | g| }|S r'   )r!   spawn)functionargskwargsgreenlets       r*   _start_new_greenletr2   P   sA    >>(<T<V< O >>(2T2Or+   c                 .    t        t        | ||            S r'   )r   r2   )r.   r/   r0   s      r*   r   r   W   s    (4@AAr+   Tc                 f    t        |       }|#t        |t              sJ |j                  |       |S )a  
    *For internal use only*: start a new thread.

    Like start_new_thread(), this starts a new thread calling the given function.
    Unlike start_new_thread(), this returns a handle object with methods to join
    or detach the given thread.
    This function is not for third-party code, please use the
    `threading` module instead. During finalization the runtime will not wait for
    the thread to exit if daemon is True. If handle is provided it must be a
    newly created thread._ThreadHandle instance.
    )r2   
isinstancer   _set_greenlet)r.   handledaemonr1   s       r*   r   r   Z   s7    2 #8,H&-000X&Mr+   c                   L    e Zd Zd ZdZd Zd Zd Zed        Z	d Z
d
dZd	 Zy)r   c                      y)zDoes nothing; ignores argsN )self_args_kwargss      r*   __init__z_ThreadHandle.__init__~   s    r+   Nc                 2    ddl m} |J  ||      | _        y )Nr   )ref)weakrefrA   _greenlet_ref)r<   gletrA   s      r*   r6   z_ThreadHandle._set_greenlet   s     Yr+   c                 >    | j                   | j                         S d S r'   )rC   r<   s    r*   _get_greenletz_ThreadHandle._get_greenlet   s-     !!-  	
 	
r+   c                 *   | j                         }||t               u rt        d      t        |d      r|j	                  |      S ddlm} d }|r
 |       |z   }| j                         s)| |       |kD  ry t        d       | j                         s)y )NzCannot joint current threadjoinr   )timeMbP?)rG   r   RuntimeErrorhasattrrI   rJ   is_doner   )r<   timeoutrD   rJ   ends        r*   rI   z_ThreadHandle.join   s     !!#z|#"#@AAtV$yy)) "Cfw&lln?tv|e lln r+   c                 >    | j                         }|t        |      S y r'   )rG   r   r<   rD   s     r*   identz_ThreadHandle.ident   s#    !!#T?"r+   c                 @    | j                         }|y|j                  S NT)rG   deadrR   s     r*   rN   z_ThreadHandle.is_done   s"    !!#<yyr+   c                 .    d| _         |rt        d       yy)a
  
        Mark the thread as complete.

        This releases our reference (if any) to our greenlet.

        By default, this will bounce back to the hub so that waiters
        in ``join`` can get notified. Set *enter_hub* to false not to
        do this.
        NrK   )rC   r   )r<   	enter_hubs     r*   	_set_donez_ThreadHandle._set_done   s     " %L r+   c                     d| j                   j                  | j                   j                  t        |       | j	                         fz  S )Nz<%s.%s at 0x%x greenlet=%r>)	__class__
__module____name__r(   rG   rF   s    r*   __repr__z_ThreadHandle.__repr__   sA    ,NN%%NN##tH 	0
 
 	
r+   )T)r]   r\   __qualname__r?   rC   r6   rG   rI   propertyrS   rN   rY   r^   r;   r+   r*   r   r   {   s@    ) M'

2  $
r+   r   c                  L    t               }|j                  t                      |S )z
    Called on 3.13 after forking in the child.
    Takes ``(module, ident)``, returns a handle object
    with that ident.
    )r   r6   r   )r=   r7   s     r*   r   r      s      _F
&Mr+   c                   r     e Zd ZdZej
                  ZereZej                  Z
 fdZed        ZddZ xZS )r   z
    The basic lock type.

    .. versionchanged:: 24.10.1
       Subclassing this object is no longer allowed. This matches the
       Python 3 API.
    c                 "    t         |           y)z
        .. versionchanged:: 24.10.1
           No longer accepts arguments to pass to the super class. If you
           want a semaphore with a different count, use a semaphore class directly.
           This matches the Lock API of Python 3
        N)superr?   )r<   r[   s    r*   r?   zLockType.__init__   s     	r+   c                     t         r'   )	TypeError)clss    r*   __init_subclass__zLockType.__init_subclass__   s    r+   c                 &   |dk(  rd }|s|t        d      |*|dk  rt        d      || j                  kD  rt        d      	 t        j                  | ||      }|s |st               t               ur
t                |S # t
        $ r |r d}Y 4w xY w)Nz/can't specify a timeout for a non-blocking callr   z'timeout value must be strictly positiveztimeout value is too largeF)	
ValueError_TIMEOUT_MAXOverflowErrorr"   acquirer$   r   r    r   )r<   blockingrO   acquireds       r*   rn   zLockType.acquire   s     b=GG/NOO{ !JKK***#$@AA		'//hHH Z\ARAT-T G)  	
 H	s   A? ?BB)Trj   )r]   r\   r_   __doc__
__thread__r   _OVER_RELEASE_ERRORr   rL   r   rl   r?   classmethodrh   rn   __classcell__)r[   s   @r*   r   r      sJ     %*** ))L  +r+   r   c                      t         r'   r   r;   r+   r*   r   r   1  s    
r+   r   c                 L    | 
t               S | t               kD  rt        |       S y r'   )_original_stack_size)sizes    r*   r   r   8  s,    <'))&(('-- )r+   )
only_namesignore_missing_namesr	   r'   )r;   NrU   )-rq   sysversion_info__implements____imports__r   rr   
__target__appendrM   r   gevent._compatr   gevent._utilr   
gevent.hubr   r   r   gevent._hub_localr    gevent.greenletr!   gevent.lockr"   gevent.localr#   r	   gevent.exceptionsr$   r   r2   r   r   r   r   r   r   r   r   r   rx   removeglobals__all__r;   r+   r*   <module>r      so  	  	bqW$
+$ i 
      ? # :/0/0  % ! #  / $ ( ( & :wwBBW
 W
r	J J^    :|$%00. ,':wy&1046 ;
& x r+   