
    h                     R    S r SSKJr  SSKJr  SSKJr  SS/0rS/r	 " S	 S\
5      rg
)z,
IO/concurrency helpers for `tqdm.contrib`.
    )deque)ThreadPoolExecutor   )tqdmzgithub.com/	casperdcl
MonoWorkerc                   $    \ rS rSrSrS rS rSrg)r      zw
Supports one running task and one waiting task.
The waiting task is the most recent submitted (others are discarded).
c                 B    [        SS9U l        [        / S5      U l        g )N   )max_workersr   )r   poolr   futures)selfs    K/var/www/html/env/lib/python3.13/site-packages/tqdm/contrib/utils_worker.py__init__MonoWorker.__init__   s    &15	R|    c                    U R                   n[        U5      UR                  :X  af  UR                  5       nUR	                  5       (       dA  [        U5      (       a   UR                  5       nUR                  5         UR                  U5         U R                  R                  " U/UQ70 UD6nUR                  U5        U$ ! [         a)  n[        R                  " [        U5      5         SnAgSnAff = f)z;`func(*args, **kwargs)` may replace currently waiting task.N)r   lenmaxlenpopleftdonepopcancel
appendleftr   submitappend	Exception	tqdm_autowritestr)r   funcargskwargsr   runningwaitinges           r   r   MonoWorker.submit   s    ,,w<7>>)oo'G<<>>w<<%kkmGNN$""7+	ii&&t=d=f=G NN7#N	  	$OOCF##	$s    C   
C3
C..C3)r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s    $r   N)r.   collectionsr   concurrent.futuresr   autor   r    
__author____all__objectr   r0   r   r   <module>r7      s4     1 $k]+
. r   