Ë
    æš¾j+  ã                  ó–   — d Z ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
mZ e
r
ddlmZmZmZ  ej                   e«      Z G d„ d	e«      Zy)
z¯Common functionality for concurrent processing.

The main entry point is :class:`ThreadPoolExecutor`, which extends the
standard library executor with a lazy ``imap`` method.
é    )ÚannotationsN)Údeque)ÚThreadPoolExecutor)ÚTYPE_CHECKINGÚAny)ÚCallableÚIterableÚIteratorc                  ó2   — e Zd ZdZdddœ	 	 	 	 	 	 	 	 	 dd„Zy)r   z+Subclass with a lazy consuming imap method.Né   )ÚtimeoutÚqueued_tasks_per_workerc             '  ó,  ‡‡K  — t        «       | j                  |dz   z  }}|j                  |j                  | j                  cŠ}}dˆˆfd„}	t        |ddiŽD ])  }
 | ||g|
¢­Ž «       t        |«      |k(  sŒ! |	«       –— Œ+ |r |	«       –— |rŒyy­w)ad  Ordered imap that consumes iterables just-in-time.

        References:
            https://gist.github.com/ddelange/c98b05437f80e4b16bf4fc20fde9c999

        Args:
            fn: Function to apply.
            *iterables: One (or more) iterable(s) to pass to fn (using zip) as positional argument(s).
            timeout: Per-future result retrieval timeout in seconds.
            queued_tasks_per_worker: Amount of additional items per worker to fetch from iterables to
                    fill the queue: this determines the total queue size.
                Setting 0 will result in a true just-in-time behaviour: when a worker finishes a task,
                    it waits until a result is consumed from the imap generator, at which point next()
                    is called on the input iterable(s) and a new task is submitted.
                Default 2 ensures there is always some work to pick up. Note that at imap startup,
                    the queue will fill up before the first yield occurs.

        Yields:
            Results of ``fn`` applied to items from ``iterables``, in input order.

        Example:
            long_generator = itertools.count()
            with ThreadPoolExecutor(42) as pool:
                result_generator = pool.imap(fn, long_generator)
                for result in result_generator:
                    print(result)
        é   c                 ó0   •—  ‰ «       j                  ‰«      S )z8Block until the next task is done and return the result.)Úresult)Úpopleftr   s   €€ú`/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/site-packages/smart_open/concurrency.pyÚgetz$ThreadPoolExecutor.imap.<locals>.getC   s   ø€ á“9×#Ñ# GÓ,Ð,ó    ÚstrictFN)Úreturnr   )r   Ú_max_workersr   ÚappendÚsubmitÚzipÚlen)ÚselfÚfnr   r   Ú	iterablesÚfuturesÚmaxlenr   r   r   Úargsr   s     `        @r   ÚimapzThreadPoolExecutor.imap   s™   ùè ø€ ôD  ›' 4×#4Ñ#4Ð8OÐRSÑ8SÑ#T�ˆØ")§/¡/°7·>±>À4Ç;Á;Ðˆ�˜ö	-ô ˜Ð1¨5Ñ1ò 	ˆDÙ‘6˜"Ð$˜tÒ$Ô%Ü�7‹|˜vÓ%Ù“e“ð	ñ
 Ù“%ŠKô ùs   „A4BÁ9BÂB)
r   zCallable[..., Any]r    zIterable[Any]r   zfloat | Noner   Úintr   zIterator[Any])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   © r   r   r   r      sB   „ Ù5ð !%Ø'(ñ/àð/ð "ð/ð ð	/ð
 "%ð/ð 
ô/r   r   )r)   Ú
__future__r   ÚloggingÚcollectionsr   Úconcurrent.futuresr   Ú_ThreadPoolExecutorÚtypingr   r   Úcollections.abcr   r	   r
   Ú	getLoggerr&   Úloggerr*   r   r   ú<module>r4      sC   ðñõ #ã Ý Ý Hß %áß<Ñ<à	ˆ×	Ñ	˜8Ó	$€ô2Ð,õ 2r   