§
    Þa{cµ"  ã                   ó(  — d 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	 g d¢Z
 ej        eg d¢¦  «        \  ZZZe	rdd
„Zn%d	 ej        dd¦  «         ej        dd¦  «        fd„Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )zž
A small selection of primitives that always work with
native threads. This has very limited utility and is
targeted only for the use of gevent's threadpool.
é    )Úabsolute_import)Údeque)Úmonkey)Úthread_mod_name)ÚPY3)ÚLockÚQueueÚEmptyTimeout)Ústart_new_threadÚallocate_lockÚ	get_identéÿÿÿÿc                 ót   — t          | ¦  «        j        t          ¦   «         d<   |                      |¬¦  «        S )NÚacquire_with_timeout)Útimeout)ÚtypeÚacquireÚglobals)Úlockr   s     ú3/usr/lib/python3/dist-packages/gevent/_threading.pyr   r   %   s.   € Ý,0°©J¬JÔ,>�‰	Œ	Ð(Ñ)Ø�|Š| Gˆ|Ñ,Ô,Ð,ó    ÚtimeÚsleepc                 ó˜   — |dk    r |¦   «         |z   nd }	 |                       d¦  «        rdS |� |¦   «         |k    rdS  |d¦  «         Œ5)Nr   é   FTg{®Gázt?)r   )r   r   Ú_timeÚ_sleepÚdeadlines        r   r   r   )   sl   € ð )0°2ª¨�5�5‘7”7˜WÑ$Ð$¸4ˆð	Ø�|Š|˜EÑ"Ô"ð Ø�tØÐ#¨¨©¬°8Ò(;Ð(;Ø�uØˆF�5‰MŒMˆMð	r   c                   ó<   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zdefd„Z	d„ Z
d	S )
Ú
_Condition©Ú_lockÚ_waitersc                 ó"   — || _         g | _        d S ©Nr!   )Úselfr   s     r   Ú__init__z_Condition.__init__?   s   € ð ˆŒ
ØˆŒˆˆr   c                 ó4   — | j                              ¦   «         S r%   )r"   Ú	__enter__©r&   s    r   r)   z_Condition.__enter__J   s   € ØŒz×#Ò#Ñ%Ô%Ð%r   c                 ó:   — | j                              |||¦  «        S r%   )r"   Ú__exit__)r&   ÚtÚvÚtbs       r   r,   z_Condition.__exit__M   s   € ØŒz×"Ò" 1 a¨Ñ,Ô,Ð,r   c                 ó>   — d| j         t          | j        ¦  «        fz  S )Nz<Condition(%s, %d)>)r"   Úlenr#   r*   s    r   Ú__repr__z_Condition.__repr__P   s   € Ø$¨¬
µC¸¼Ñ4FÔ4FÐ'GÑGÐGr   r   c                 óÚ  — d}|                      ¦   «          | j                             |¦  «         | j                             ¦   «          	  |||¦  «        }| j                              ¦   «          n# | j                              ¦   «          w xY w|s|                      d¦  «        }|s/| j                             |¦  «         |                     ¦   «          n|                     ¦   «          |S )NTF)r   r#   Úappendr"   ÚreleaseÚremove)r&   Ú	wait_lockr   Ú_wait_for_notifyÚgevent_threadpool_worker_idleÚnotifieds         r   Úwaitz_Condition.waitS   sÿ   € ð )-Ð%ð
 	×ÒÑÔÐØŒ×Ò˜YÑ'Ô'Ð'àŒ
×ÒÑÔÐð	!ð (Ð'¨	°7Ñ;Ô;ˆHàŒJ×ÒÑ Ô Ð Ð øˆDŒJ×ÒÑ Ô Ð Ð øøøð ð 	0ð
 !×(Ò(¨Ñ/Ô/ˆHØð 	 àŒM× Ò  Ñ+Ô+Ð+ð ×ÒÑÔÐÐð ×ÒÑÔÐØˆs   ÁA1 Á1Bc                 ó„   — 	 | j                              ¦   «         }|                     ¦   «          d S # t          $ r Y d S w xY wr%   )r#   Úpopr5   Ú
IndexError)r&   Úwaiters     r   Ú
notify_onez_Condition.notify_onez   sV   € ð		Ø”]×&Ò&Ñ(Ô(ˆFð �NŠNÑÔÐÐÐøõ ð 	ð 	ð 	àˆDˆDð	øøøs   ‚1 ±
?¾?N)Ú__name__Ú
__module__Ú__qualname__Ú	__slots__r'   r)   r,   r2   r   r;   r@   © r   r   r    r    4   s†   € € € € € ð€Ið
ð ð ð&ð &ð &ð-ð -ð -ðHð Hð Hð ')Ð;Oð %ð %ð %ð %ðNð ð ð ð r   r    c                   ó   — e Zd ZdZdS )r
   zERaised from :meth:`Queue.get` if no item is available in the timeout.N)rA   rB   rC   Ú__doc__rE   r   r   r
   r
   ‡   s   € € € € € ØOÐOÐOÐOr   r
   c                   óR   — e Zd ZdZdZd„ Zd„ Zefd„Zd„ Z	d„ Z
d„ Zdd
„Zd„ Zd„ ZdS )r	   zH
    Create a queue object.

    The queue is always infinite size.
    ©Ú_queueÚ_mutexÚ
_not_emptyÚunfinished_tasksc                 ó’   — t          ¦   «         | _        t          ¦   «         | _        t	          | j        ¦  «        | _        d| _        d S )Nr   )r   rJ   r   rK   r    rL   rM   r*   s    r   r'   zQueue.__init__”   s;   € Ý‘g”gˆŒõ
 ‘f”fˆŒõ % T¤[Ñ1Ô1ˆŒà !ˆÔÐÐr   c                 ó®   — | j         5  | j        dz
  }|dk    r|dk     rt          d| j        z  ¦  «        ‚|| _        ddd¦  «         dS # 1 swxY w Y   dS )a.  Indicate that a formerly enqueued task is complete.

        Used by Queue consumer threads.  For each get() used to fetch a task,
        a subsequent call to task_done() tells the queue that the processing
        on the task is complete.

        If a join() is currently blocking, it will resume when all items
        have been processed (meaning that a task_done() call was received
        for every item that had been put() into the queue).

        Raises a ValueError if called more times than there were items
        placed in the queue.
        r   r   z5task_done() called too many times; %s remaining tasksN)rK   rM   Ú
ValueError)r&   Ú
unfinisheds     r   Ú	task_donezQueue.task_done¡   s¹   € ð Œ[ð 		/ð 		/ØÔ.°Ñ2ˆJØ˜QŠˆØ ’>�>Ý$ØOØ Ô1ññô ð ð
 %/ˆDÔ!ð		/ð 		/ð 		/ñ 		/ô 		/ð 		/ð 		/ð 		/ð 		/ð 		/ð 		/ð 		/øøøð 		/ð 		/ð 		/ð 		/ð 		/ð 		/s   ˆ5A
Á
AÁAc                 ó"   —  || j         ¦  «        S )z9Return the approximate size of the queue (not reliable!).)rJ   )r&   r1   s     r   ÚqsizezQueue.qsizeº   s   € àˆs�4”;ÑÔÐr   c                 ó,   — |                       ¦   «          S )zCReturn True if the queue is empty, False otherwise (not reliable!).)rT   r*   s    r   ÚemptyzQueue.empty¾   s   € à—:’:‘<”<ÐÐr   c                 ó   — dS )zBReturn True if the queue is full, False otherwise (not reliable!).FrE   r*   s    r   Úfullz
Queue.fullÂ   s   € àˆur   c                 óÌ   — | j         5  | j                             |¦  «         | xj        dz  c_        | j                             ¦   «          ddd¦  «         dS # 1 swxY w Y   dS )z$Put an item into the queue.
        r   N)rK   rJ   r4   rM   rL   r@   )r&   Úitems     r   Úputz	Queue.putÆ   s®   € ð Œ[ð 	)ð 	)ØŒK×Ò˜tÑ$Ô$Ð$ØÐ!Ô! QÑ&Ð!Ô!ØŒO×&Ò&Ñ(Ô(Ð(ð	)ð 	)ð 	)ñ 	)ô 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)øøøð 	)ð 	)ð 	)ð 	)ð 	)ð 	)s   ˆAAÁAÁ Ar   c                 óì   — | j         5  | j        s2| j                             ||¦  «        }|s| j        st          ‚| j        ¯2| j                             ¦   «         }|cddd¦  «         S # 1 swxY w Y   dS )a"  
        Remove and return an item from the queue.

        If *timeout* is given, and is not -1, then we will
        attempt to wait for only that many seconds to get an item.
        If those seconds elapse and no item has become available,
        raises :class:`EmptyTimeout`.
        N)rK   rJ   rL   r;   r
   Úpopleft)r&   Úcookier   r:   rZ   s        r   Úgetz	Queue.getÎ   sÐ   € ð Œ[ð 	ð 	Ø”kð 	'ð  œ?×/Ò/°¸Ñ@Ô@�ð  ð '¨¬ð 'Ý&Ð&ð ”kð 	'ð ”;×&Ò&Ñ(Ô(ˆDØð	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   ˆAA)Á)A-Á0A-c                 ó   — t          ¦   «         S )z†
        Create and return the *cookie* to pass to `get()`.

        Each thread that will use `get` needs a distinct cookie.
        )r   r*   s    r   Úallocate_cookiezQueue.allocate_cookieå   s   € õ ‰vŒvˆr   c                 ó>   — d| _         d| _        d| _        d| _        dS )z·
        Call to destroy this object.

        Use this when it's not possible to safely drain the queue, e.g.,
        after a fork when the locks are in an uncertain state.
        NrI   r*   s    r   Úkillz
Queue.killí   s'   € ð ˆŒØˆŒØˆŒØ $ˆÔÐÐr   N©r   )rA   rB   rC   rG   rD   r'   rR   r1   rT   rV   rX   r[   r_   ra   rc   rE   r   r   r	   r	   ‹   s¼   € € € € € ðð ð G€Ið"ð "ð "ð/ð /ð /ð2 ð  ð  ð  ð  ð ð  ð  ðð ð ð)ð )ð )ðð ð ð ð.ð ð ð
%ð 
%ð 
%ð 
%ð 
%r   r	   Nrd   )rG   Ú
__future__r   Úcollectionsr   Úgeventr   Úgevent._compatr   r   Ú__all__Úget_originalr   r   Úget_thread_identr   Úobjectr    Ú	Exceptionr
   r	   rE   r   r   ú<module>rn      s³  ððð ð
 'Ð &Ð &Ð &Ð &Ð &à Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø *Ð *Ð *Ð *Ð *Ð *Ø Ð Ð Ð Ð Ð ðð ð €ð -@¨FÔ,?Àð Rð Rð Rñ -ô -Ñ )Ð �$Ð(ð ð ð-ð -ð -ð -ð -ð ,.Ø#6 6Ô#6°v¸vÑ#FÔ#FØ$7 FÔ$7¸ÀÑ$HÔ$Hð	ð 	ð 	ð 	ðQð Qð Qð Qð Q�ñ Qô Qð QðfPð Pð Pð Pð P�9ñ Pô Pð Pðl%ð l%ð l%ð l%ð l%ˆFñ l%ô l%ð l%ð l%ð l%r   