
    g                        d dl mZ d dlZd dlZd dlmZ d dlmZ erd dlmZ d dl	m
Z
  ej                  e      Z G d de      Zy)	    )annotationsN)TYPE_CHECKING)
BaseThread)Callable)FileSystemEventc                  L     e Zd ZdZ	 	 	 	 	 	 d fdZddZd fdZddZ xZS )	EventDebouncera  Background thread for debouncing event handling.

    When an event is received, wait until the configured debounce interval
    passes before calling the callback.  If additional events are received
    before the interval passes, reset the timer and keep waiting.  When the
    debouncing interval passes, the callback will be called with a list of
    events in the order in which they were received.
    c                ~    t         |           || _        || _        g | _        t        j                         | _        y N)super__init__debounce_interval_secondsevents_callback_events	threading	Condition_cond)selfr   r   	__class__s      S/var/www/openai/venv/lib/python3.12/site-packages/watchdog/utils/event_debouncer.pyr   zEventDebouncer.__init__   s7    
 	)B&..0((*
    c                    | j                   5  | j                  j                  |       | j                   j                          d d d        y # 1 sw Y   y xY wr   )r   r   appendnotify)r   events     r   handle_eventzEventDebouncer.handle_event'   s5    ZZLL&JJ ZZs   6AAc                    | j                   5  t        | 	          | j                   j                          d d d        y # 1 sw Y   y xY wr   )r   r   stopr   )r   r   s    r   r   zEventDebouncer.stop,   s-    ZZGLNJJ ZZs   )A  A	c                   | j                   5  	 | j                   j                          | j                  rH| j                         r8| j                   j                  | j                        sn| j                         r8| j                         sn%| j                  }g | _        | j                  |       	 d d d        y # 1 sw Y   y xY w)N)timeout)r   waitr   should_keep_runningr   r   )r   eventss     r   runzEventDebouncer.run1   s    ZZ

!11224#zzt7U7UV! 224 //1!$$V,   ZZs   A/B==6B==C)r   intr   z'Callable[[list[FileSystemEvent]], None]returnNone)r   r   r&   r'   )r&   r'   )	__name__
__module____qualname____doc__r   r   r   r$   __classcell__)r   s   @r   r	   r	      s9    
+#&
+ A
+ 
	
+ 
 
-r   r	   )
__future__r   loggingr   typingr   watchdog.utilsr   r   watchdog.eventsr   	getLoggerr(   loggerr	    r   r   <module>r5      s;    "     %/			8	$1-Z 1-r   