
    0Rj                     l    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e	      Z
 G d de      Zy)	    N)EventThreadcurrent_thread)time)warnTMonitorTqdmSynchronisationWarningc                       e Zd ZdZy)r	   zr
    tqdm multi-thread/-process errors which may cause incorrect nesting
    but otherwise no adverse effects
    N)__name__
__module____qualname____doc__     U/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/tqdm/_monitor.pyr	   r	   	   s    r   c                   8    e Zd ZdZi Zd Zd Zd Zd Zd Z	d Z
y)	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                 f   t        j                  | d       d| _        d| _        || _        || _        | j                  j                  dt              | _	         | j                  j                  dt                     | _        t        j                  | j                         | j                          y )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   s      r   r   zTMonitor.__init__   sy    >2
 ,ZZ^^FD1
8$**..%8:++,

r   c                 8    | j                   j                          y)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#   s    r   r!   zTMonitor._atexit_signal*   s     	r   c                     | j                   j                          | t               ur| j                          | j	                         S N)r   r%   r   joinreportr&   s    r   exitzTMonitor.exit2   s2    ~''IIK{{}r   c                     | j                   j                  j                         D cg c]  }t        |d      r| c}S c c}w )Nstart_t)r   
_instancescopyhasattr)r#   is     r   get_instanceszTMonitor.get_instances8   s>    ==3388: *a1i(  * 	* *s   ?c                    | j                         }	 || _        | j                  j                  | j                         | j                  j                         ry | j                  j                         5  | j                         }| j                         }|D ]k  }| j                  j                         r
 d d d        y |j                  dkD  r5||j                  z
  |j                  k\  rd|_	        |j                  d       ~m || j                         k7  rt        dt        d       ~d d d        "# 1 sw Y   xY w)NT   )nolockzOSet changed size during iteration (see https://github.com/tqdm/tqdm/issues/481)   )
stacklevel)r   r   r   waitr   is_setr   get_lockr2   miniterslast_print_tmaxintervalrefreshr   r	   )r#   cur_t	instancesinstances       r   runzTMonitor.run>   s(   

 DJOO  !4!45%%' '') 

 ..0	 ) !H--/  !))A-"X%:%::x?S?SS -.) (((5 !!"  2 2 44 J3C 5  s   3AD4=A-D44D=c                 8    | j                   j                          S r(   )r   r9   r&   s    r   r*   zTMonitor.reportg   s    ??))+++r   N)r   r   r   r   r   r   r!   r+   r2   rB   r*   r   r   r   r   r      s-     E	*'R,r   )r   	threadingr   r   r   r   warningsr   __all__RuntimeWarningr	   r   r   r   r   <module>rH      s9     3 3  3
4 X,v X,r   