o
    nN)j­  ã                   @   s`   d dl Z d dlmZmZmZ d dlmZ d dlmZ ddgZG dd„ de	ƒZ
G dd„ deƒZdS )	é    N)ÚEventÚThreadÚcurrent_thread)Útime)ÚwarnÚTMonitorÚTqdmSynchronisationWarningc                   @   s   e Zd ZdZdS )r   zr
    tqdm multi-thread/-process errors which may cause incorrect nesting
    but otherwise no adverse effects
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ún/var/www/html/finance.cargoinsureonline.com/_shared/backend-venv/lib/python3.10/site-packages/tqdm/_monitor.pyr   	   s    c                   @   sD   e Zd ZdZi Zdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dS )r   a^  
    Monitoring thread for tqdm bars.
    Monitors if tqdm bars are taking too much time to display
    and readjusts miniters automatically if necessary.

    Parameters
    ----------
    tqdm_cls  : class
        tqdm class to use (can be core tqdm or a submodule).
    sleep_interval  : float
        Time to sleep between monitoring checks.
    c                 C   s`   t j| dd d| _d| _|| _|| _| j dt¡| _	| j dt
¡ƒ | _t | j¡ |  ¡  d S )NÚtqdm_monitor)ÚnameTr   r   r   )r   Ú__init__ÚdaemonÚwokenÚtqdm_clsÚsleep_intervalÚ_testÚgetr   Ú_timer   Ú
was_killedÚatexitÚregisterÚ_atexit_signalÚstart)Úselfr   r   r   r   r   r      s   zTMonitor.__init__c                 C   s   | j  ¡  dS )zÎ
        Non-joining shutdown signal.
        Avoids deadlocks at interpreter exit from other threads, dead forks, etc.
        This daemon thread is auto-reaped on shutdown without needing a join.
        N)r   Úset©r   r   r   r   r   *   s   zTMonitor._atexit_signalc                 C   s$   | j  ¡  | tƒ ur|  ¡  |  ¡ S ©N)r   r   r   ÚjoinÚreportr    r   r   r   Úexit2   s   

zTMonitor.exitc                 C   s   dd„ | j j ¡ D ƒS )Nc                 S   s   g | ]	}t |d ƒr|‘qS )Ústart_t)Úhasattr)Ú.0Úir   r   r   Ú
<listcomp>:   s    
þz*TMonitor.get_instances.<locals>.<listcomp>)r   Ú
_instancesÚcopyr    r   r   r   Úget_instances8   s   zTMonitor.get_instancesc                 C   sØ   |   ¡ }	 || _| j | j¡ | j ¡ rd S | j ¡ H |   ¡ }|  ¡ }|D ]'}| j ¡ r6 W d   ƒ d S |j	dkrL||j
 |jkrLd|_	|jdd ~q&||  ¡ kr[tdtdd ~W d   ƒ n1 sfw   Y  q)NTé   )ÚnolockzOSet changed size during iteration (see https://github.com/tqdm/tqdm/issues/481)é   )Ú
stacklevel)r   r   r   Úwaitr   Úis_setr   Úget_lockr,   ÚminitersÚlast_print_tÚmaxintervalÚrefreshr   r   )r   Úcur_tÚ	instancesÚinstancer   r   r   Úrun>   s2   

ù
þæõzTMonitor.runc                 C   s   | j  ¡  S r!   )r   r2   r    r   r   r   r#   g   s   zTMonitor.reportN)r	   r
   r   r   r   r   r   r$   r,   r;   r#   r   r   r   r   r      s    ))r   Ú	threadingr   r   r   r   Úwarningsr   Ú__all__ÚRuntimeWarningr   r   r   r   r   r   Ú<module>   s    