§
    Hºi&  ã                   óŠ   — d dl Z d dlZd dlmZ d dlmZ ddgZdZ G d„ d¦  «        Z G d„ d¦  «        Z	 G d	„ d
e	¦  «        Z
dS )é    N)Úqueue)Ú	greenletsÚ	GreenPoolÚ	GreenPileTc                   ób   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )r   z4The GreenPool class is a pool of green threads.
    éè  c                 óÎ  — 	 t          |¦  «        }nQ# t          $ rD}d                     t          |¦  «        t	          |¦  «        ¦  «        }t          |¦  «        ‚d }~ww xY w|dk     r1d                     t          |¦  «        ¦  «        }t          |¦  «        ‚|| _        t          ¦   «         | _	        t          j        |¦  «        | _        t          j        ¦   «         | _        d S )Nz-GreenPool() expect size :: int, actual: {} {}r   z(GreenPool() expect size >= 0, actual: {})ÚintÚ
ValueErrorÚformatÚtypeÚstrÚ	TypeErrorÚreprÚsizeÚsetÚcoroutines_runningÚeventletÚ	SemaphoreÚsemÚEventÚno_coros_running)Úselfr   ÚeÚmsgs       úW/home/mmwave/public_html/mmwave/venv/lib/python3.11/site-packages/eventlet/greenpool.pyÚ__init__zGreenPool.__init__   sÏ   € ð	!Ý�t‘9”9ˆDˆDøÝð 	!ð 	!ð 	!ØA×HÒHÍÈdÉÌÕUXÐYZÑU[ÔU[Ñ\Ô\ˆCÝ˜C‘.”.Ð øøøøð	!øøøð �!Š8ˆ8Ø<×CÒCÅDÈÁJÄJÑOÔOˆCÝ˜S‘/”/Ð!ØˆŒ	Ý"%¡%¤%ˆÔÝÔ% dÑ+Ô+ˆŒÝ (¤Ñ 0Ô 0ˆÔÐÐs   ‚ ’
A œ?AÁA c                 óR   — || j         z
  }| j        xj        |z  c_        || _         dS )a½   Change the max number of greenthreads doing work at any given time.

        If resize is called when there are more than *new_size* greenthreads
        already working on tasks, they will be allowed to complete but no new
        tasks will be allowed to get launched until enough greenthreads finish
        their tasks to drop the overall quantity below *new_size*.  Until
        then, the return value of free() will be negative.
        N)r   r   Úcounter)r   Únew_sizeÚ
size_deltas      r   ÚresizezGreenPool.resize   s1   € ð  ¤	Ñ)ˆ
ØŒÐÔ˜JÑ&ÐÔØˆŒ	ˆ	ˆ	ó    c                 ó*   — t          | j        ¦  «        S )zd Returns the number of greenthreads that are currently executing
        functions in the GreenPool.)Úlenr   ©r   s    r   ÚrunningzGreenPool.running+   s   € õ �4Ô*Ñ+Ô+Ð+r#   c                 ó   — | j         j        S )zÍ Returns the number of greenthreads available for use.

        If zero or less, the next call to :meth:`spawn` or :meth:`spawn_n` will
        block the calling greenthread until a slot becomes available.)r   r   r&   s    r   ÚfreezGreenPool.free0   s   € ð
 ŒxÔÐr#   c                 óâ  — t          j        ¦   «         }| j                             ¦   «         rA|| j        v r8t           j                             |¦  «        }|                     |||¦  «         |S | j                             ¦   «          t          j	        |g|¢R i |¤Ž}| j        st          j
        ¦   «         | _        | j                             |¦  «         |                     | j        ¦  «         |S )a
  Run the *function* with its arguments in its own green thread.
        Returns the :class:`GreenThread <eventlet.GreenThread>`
        object that is running the function, which can be used to retrieve the
        results.

        If the pool is currently at capacity, ``spawn`` will block until one of
        the running greenthreads completes its task and frees up a slot.

        This function is reentrant; *function* can call ``spawn`` on the same
        pool without risk of deadlocking the whole thing.
        )r   Ú
getcurrentr   Úlockedr   ÚgreenthreadÚGreenThreadÚmainÚacquireÚspawnr   r   ÚaddÚlinkÚ_spawn_done)r   ÚfunctionÚargsÚkwargsÚcurrentÚgts         r   r1   zGreenPool.spawn7   sã   € õ Ô%Ñ'Ô'ˆØŒ8�?Š?ÑÔð 	& ¨DÔ,CÐ!CÐ!CåÔ%×1Ò1°'Ñ:Ô:ˆBØ�GŠG�H˜d FÑ+Ô+Ð+ØˆIàŒH×ÒÑÔÐÝ” Ð:¨4Ð:Ð:Ð:°6Ð:Ð:ˆBØÔ*ð 9Ý(0¬Ñ(8Ô(8�Ô%ØÔ#×'Ò'¨Ñ+Ô+Ð+Ø�GŠG�DÔ$Ñ%Ô%Ð%Øˆ	r#   c                 óN  — 	 	  ||i |¤Ž n=# t           t          t          j        f$ r ‚  t          rt          j        ¦   «          Y nxY w|�*t          j        ¦   «         }|  	                    |¦  «         d S d S # |�)t          j        ¦   «         }|  	                    |¦  «         w w xY w©N)
ÚKeyboardInterruptÚ
SystemExitÚgreenletÚGreenletExitÚDEBUGÚ	tracebackÚ	print_excr   r+   r4   )r   Úfuncr6   r7   Úcoros        r   Ú_spawn_n_implzGreenPool._spawn_n_implT   sÎ   € ð	'ð*Ø��dÐ%˜fÐ%Ð%Ð%Ð%øÝ%¥zµ8Ô3HÐIð ð ð Øð*Ýð *ÝÔ'Ñ)Ô)Ð)øøøøøàÐÝÔ*Ñ,Ô,�Ø× Ò  Ñ&Ô&Ð&Ð&Ð&ð  ÐøˆtÐÝÔ*Ñ,Ô,�Ø× Ò  Ñ&Ô&Ð&Ð&ð  øøøs   ƒ ‹A7 Œ8AÁA7 Á7-B$c                 ó‚  — t          j        ¦   «         }| j                             ¦   «         r#|| j        v r|                      |||d¦  «         dS | j                             ¦   «          t          j        | j        |||d¦  «        }| j        st          j        ¦   «         | _	        | j         
                    |¦  «         dS )zÄCreate a greenthread to run the *function*, the same as
        :meth:`spawn`.  The difference is that :meth:`spawn_n` returns
        None; the results of *function* are not retrievable.
        NT)r   r+   r   r,   r   rE   r0   Úspawn_nr   r   r2   )r   r5   r6   r7   r8   Úgs         r   rG   zGreenPool.spawn_nb   sÂ   € õ Ô%Ñ'Ô'ˆØŒ8�?Š?ÑÔð 		+ ¨DÔ,CÐ!CÐ!CØ×Ò˜x¨¨v°tÑ<Ô<Ð<Ð<Ð<àŒH×ÒÑÔÐÝÔ ØÔ"Ø˜$ ¨ñ.ô .ˆAð Ô*ð 9Ý(0¬Ñ(8Ô(8�Ô%ØÔ#×'Ò'¨Ñ*Ô*Ð*Ð*Ð*r#   c                 ó¬   — t          j        ¦   «         | j        vs
J d¦   «         ‚|                      ¦   «         r| j                             ¦   «          dS dS )z>Waits until all greenthreads in the pool are finished working.zWCalling waitall() from within one of the GreenPool's greenthreads will never terminate.N)r   r+   r   r'   r   Úwaitr&   s    r   ÚwaitallzGreenPool.waitallu   sd   € åÔ"Ñ$Ô$¨DÔ,CÐCÐCÐCð=ñ DÔCÐCð �<Š<‰>Œ>ð 	)ØÔ!×&Ò&Ñ(Ô(Ð(Ð(Ð(ð	)ð 	)r#   c                 óÒ   — | j                              ¦   «          |�| j                             |¦  «         | j         j        | j        k    r| j                             d ¦  «         d S d S r;   )r   Úreleaser   ÚremoveÚbalancer   r   Úsend)r   rD   s     r   r4   zGreenPool._spawn_done}   sl   € ØŒ×ÒÑÔÐØÐØÔ#×*Ò*¨4Ñ0Ô0Ð0ð Œ8Ô˜tœyÒ(Ð(ØÔ!×&Ò& tÑ,Ô,Ð,Ð,Ð,ð )Ð(r#   c                 ó@   — | j         j        dk     r| j         j         S dS )z<Return the number of greenthreads waiting to spawn.
        r   )r   rO   r&   s    r   ÚwaitingzGreenPool.waiting†   s'   € ð Œ8Ô˜aÒÐØ”HÔ$Ð$Ð$à�1r#   c                 óT   — |D ]} |j         |g|¢R Ž  Œ|                     ¦   «          d S r;   )r1   Údone_spawning)r   rC   ÚitÚgir6   s        r   Ú_do_mapzGreenPool._do_mapŽ   sF   € Øð 	"ð 	"ˆDØˆBŒH�TÐ!˜DÐ!Ð!Ð!Ð!Ð!Ø
×ÒÑÔÐÐÐr#   c                 óp   — |€d„ }t          | j        ¦  «        }t          j        | j        |||¦  «         |S )au  This is the same as :func:`itertools.starmap`, except that *func* is
        executed in a separate green thread for each item, with the concurrency
        limited by the pool's size. In operation, starmap consumes a constant
        amount of memory, proportional to the size of the pool, and is thus
        suited for iterating over extremely long input lists.
        Nc                  ó   — | S r;   © )Úas    r   ú<lambda>z#GreenPool.starmap.<locals>.<lambda>›   s   €  !€ r#   )ÚGreenMapr   r   rG   rW   )r   r5   ÚiterablerV   s       r   ÚstarmapzGreenPool.starmap“   s@   € ð ÐØ#�|ˆHõ �d”iÑ Ô ˆÝÔ˜œ x°¸2Ñ>Ô>Ð>Øˆ	r#   c                 ó<   — |                       |t          |Ž ¦  «        S )a�  This is the same as :func:`itertools.imap`, and has the same
        concurrency and memory behavior as :meth:`starmap`.

        It's quite convenient for, e.g., farming out jobs from a file::

           def worker(line):
               return do_something(line)
           pool = GreenPool()
           for result in pool.imap(worker, open("filename", 'r')):
               print(result)
        )r_   Úzip)r   r5   Ú	iterabless      r   ÚimapzGreenPool.imap©   s   € ð �|Š|˜H¥c¨9 oÑ6Ô6Ð6r#   N©r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r"   r'   r)   r1   rE   rG   rK   r4   rR   rW   r_   rc   rZ   r#   r   r   r      sæ   € € € € € ðð ð1ð 1ð 1ð 1ðð ð ð,ð ,ð ,ð
 ð  ð  ðð ð ð:'ð 'ð 'ð+ð +ð +ð&)ð )ð )ð-ð -ð -ðð ð ðð ð ð
ð ð ð,7ð 7ð 7ð 7ð 7r#   c                   ó6   — e Zd ZdZd	d„Zd„ Zd„ Zd„ ZeZd„ Z	dS )
r   a�  GreenPile is an abstraction representing a bunch of I/O-related tasks.

    Construct a GreenPile with an existing GreenPool object.  The GreenPile will
    then use that pool's concurrency as it processes its jobs.  There can be
    many GreenPiles associated with a single GreenPool.

    A GreenPile can also be constructed standalone, not associated with any
    GreenPool.  To do this, construct it with an integer size parameter instead
    of a GreenPool.

    It is not advisable to iterate over a GreenPile in a different greenthread
    than the one which is calling spawn.  The iterator will exit early in that
    situation.
    r   c                 ó¦   — t          |t          ¦  «        r|| _        nt          |¦  «        | _        t          j        ¦   «         | _        d| _        d S )Nr   )Ú
isinstancer   Úpoolr   Ú
LightQueueÚwaitersr   )r   Úsize_or_pools     r   r   zGreenPile.__init__È   sG   € Ý�l¥IÑ.Ô.ð 	0Ø$ˆDŒIˆIå! ,Ñ/Ô/ˆDŒIÝÔ'Ñ)Ô)ˆŒØˆŒˆˆr#   c                 ó´   — | xj         dz  c_         	  | j        j        |g|¢R i |¤Ž}| j                             |¦  «         dS #  | xj         dz  c_         ‚ xY w)znRuns *func* in its own green thread, with the result available by
        iterating over the GreenPile object.é   N)r   rl   r1   rn   Úput)r   rC   r6   Úkwr9   s        r   r1   zGreenPile.spawnÐ   st   € ð 	ˆŒ˜ÑˆŒð	Ø �”” Ð3¨Ð3Ð3Ð3°Ð3Ð3ˆBØŒL×Ò˜RÑ Ô Ð Ð Ð øð	ØˆLŒL˜AÑˆLŒLØøøøs   ’0A ÁAc                 ó   — | S r;   rZ   r&   s    r   Ú__iter__zGreenPile.__iter__Û   s   € Øˆr#   c                 ó\   — | j         dk    rt          ¦   «         ‚|                      ¦   «         S )z‘Wait for the next result, suspending the current greenthread until it
        is available.  Raises StopIteration when there are no more results.r   )r   ÚStopIterationÚ_nextr&   s    r   ÚnextzGreenPile.nextÞ   s)   € ð Œ<˜1ÒÐÝ‘/”/Ð!Ø�zŠz‰|Œ|Ðr#   c                 ó¤   — 	 | j                              ¦   «                              ¦   «         | xj        dz  c_        S # | xj        dz  c_        w xY w)Nrq   )rn   ÚgetrJ   r   r&   s    r   rx   zGreenPile._nextæ   sN   € ð	Ø”<×#Ò#Ñ%Ô%×*Ò*Ñ,Ô,àˆLŒL˜AÑˆLŒLˆLøˆDˆLŒL˜AÑˆLŒLˆLˆLˆLˆLs	   ‚*= ½ANrd   )
re   rf   rg   rh   r   r1   ru   ry   Ú__next__rx   rZ   r#   r   r   r   ¸   su   € € € € € ðð ðð ð ð ð	ð 	ð 	ðð ð ðð ð ð €Hðð ð ð ð r#   c                   ó.   ‡ — e Zd Zˆ fd„Zd„ Zd„ ZeZˆ xZS )r]   c                 ó’   •— t          ¦   «                              |¦  «         t          j        | j        j        ¬¦  «        | _        d S )N)Úmaxsize)Úsuperr   r   rm   rl   r   rn   )r   ro   Ú	__class__s     €r   r   zGreenMap.__init__ñ   s8   ø€ Ý‰Œ×Ò˜Ñ&Ô&Ð&ÝÔ'°´	´Ð?Ñ?Ô?ˆŒˆˆr#   c                 ó2   — |                       d„ ¦  «         d S )Nc                  ó   — t          ¦   «         S r;   )rw   rZ   r#   r   r\   z(GreenMap.done_spawning.<locals>.<lambda>ö   s
   € �=™?œ?€ r#   )r1   r&   s    r   rT   zGreenMap.done_spawningõ   s   € Ø�
Š
Ð*Ð*Ñ+Ô+Ð+Ð+Ð+r#   c                 ó\   — |                       ¦   «         }t          |t          ¦  «        r|‚|S r;   )rx   rk   rw   )r   Úvals     r   ry   zGreenMap.nextø   s+   € Ø�jŠj‰lŒlˆÝ�c�=Ñ)Ô)ð 	ØˆIàˆJr#   )re   rf   rg   r   rT   ry   r|   Ú__classcell__)r�   s   @r   r]   r]   ð   sV   ø€ € € € € ð@ð @ð @ð @ð @ð,ð ,ð ,ðð ð ð €H€H€H€H€Hr#   r]   )rA   r   r   Úeventlet.supportr   r>   Ú__all__r@   r   r   r]   rZ   r#   r   ú<module>r‰      sÛ   ðØ Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2à˜Ð
$€à€ði7ð i7ð i7ð i7ð i7ñ i7ô i7ð i7ðX2ð 2ð 2ð 2ð 2ñ 2ô 2ð 2ðpð ð ð ð ˆyñ ô ð ð ð r#   