o
    r¨Êhj  ã                   @   s`   d dl mZmZmZ d dlmZ d dlmZ d dlZddgZG dd„ de	ƒZ
G dd„ deƒZdS )	é    )ÚEventÚThreadÚcurrent_thread)Útime)ÚwarnNÚTMonitorÚTqdmSynchronisationWarningc                   @   s   e Zd ZdZdS )r   zhtqdm multi-thread/-process errors which may cause incorrect nesting
    but otherwise no adverse effectsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú?/var/www/html/env/lib/python3.10/site-packages/tqdm/_monitor.pyr      s    c                   @   s@   e Zd ZdZdZ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  : fload
        Time to sleep between monitoring checks.
    Nc                 C   sv   t  | ¡ d| _tƒ | _d| _|| _|| _tj	d urtj	| _	nt
| _	tjd ur,tj| _nt| _t | j¡ |  ¡  d S )NTr   )r   Ú__init__Údaemonr   Ú
was_killedÚwokenÚtqdm_clsÚsleep_intervalr   Ú_timer   Ú_eventÚatexitÚregisterÚexitÚstart)Úselfr   r   r   r   r   r       s   




zTMonitor.__init__c                 C   s$   | j  ¡  | tƒ ur|  ¡  |  ¡ S ©N)r   Úsetr   ÚjoinÚreport©r   r   r   r   r   2   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 ¡ �F |   ¡ }|  ¡ }|D ]&}| j ¡ r6 W d   ƒ d S |j	dkrL||j
 |jkrLd|_	|jdd� q&||  ¡ krZtdtdd� W d   ƒ n1 sdw   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>   s6   

ù

ÿ€þ€íõzTMonitor.runc                 C   s   | j  ¡  S r   )r   r.   r    r   r   r   r   b   s   zTMonitor.report)r	   r
   r   r   r   r   r   r   r(   r7   r   r   r   r   r   r      s    $)Ú	threadingr   r   r   r   Úwarningsr   r   Ú__all__ÚRuntimeWarningr   r   r   r   r   r   Ú<module>   s    