§
    YŠtj~  ã                  ó¬   — d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZmZ  ej        e¦  «        ZeZ G d„ d¦  «        ZdS )aÞ  
A minimal scheduler to schedule tasks to run in the future (sync version).

Inspired to the standard library `sched.scheduler`, but designed for
multi-thread usage from the ground up, not as an afterthought. Tasks can be
scheduled in front of the one currently running and `Scheduler.run()` can be
left running without any tasks scheduled.

Tasks are called "Task", not "Event", here, because we actually make use of
`[threading/asyncio].Event` and the two would be confusing.
é    )ÚannotationsN)Ú	monotonic)ÚheappopÚheappush)ÚAny)ÚCallableé   )ÚTask)ÚEventÚLockc                  ó2   — e Zd Zdd„ZdZdd
„Zdd„Zdd„ZdS )Ú	SchedulerÚreturnÚNonec                ó`   — g | _         t          ¦   «         | _        t          ¦   «         | _        d S )N)Ú_queuer   Ú_lockr   Ú_event)Úselfs    úP/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/psycopg_pool/sched.pyÚ__init__zScheduler.__init__$   s#   € Ø"$ˆŒÝ‘V”VˆŒ
Ý‘g”gˆŒˆˆó    g     À‚@ÚdelayÚfloatÚactionúCallable[[], Any] | Noner
   c                óP   — t          ¦   «         |z   }|                      ||¦  «        S )zpEnter a new task in the queue delayed in the future.

        Schedule a `!None` to stop the execution.
        )r   Úenterabs)r   r   r   Útimes       r   ÚenterzScheduler.enter+   s&   € õ
 ‰{Œ{˜UÑ"ˆØ�}Š}˜T 6Ñ*Ô*Ð*r   r   c                óâ   — t          ||¦  «        }| j        5  t          | j        |¦  «         | j        d         |u }ddd¦  «         n# 1 swxY w Y   |r| j                             ¦   «          |S )znEnter a new task in the queue at an absolute time.

        Schedule a `!None` to stop the execution.
        r   N)r
   r   r   r   r   Úset)r   r   r   ÚtaskÚfirsts        r   r   zScheduler.enterabs3   s³   € õ
 �D˜&Ñ!Ô!ˆØŒZð 	+ð 	+Ý�T”[ $Ñ'Ô'Ð'Ø”K ”N dÐ*ˆEð	+ð 	+ð 	+ñ 	+ô 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+øøøð 	+ð 	+ð 	+ð 	+ð ð 	ØŒK�OŠOÑÔÐàˆs   ˜%A	Á	AÁAc                ó  — | j         }	 | j        5  t          ¦   «         }|r|d         ndx}r(|j        |k    rt	          |¦  «         n|j        |z
  }d}n| j        }| j                             ¦   «          ddd¦  «         n# 1 swxY w Y   |rb|j        sdS 	 |                     ¦   «          n]# t          $ r6}t                               d|j        |j        j        |¦  «         Y d}~n"d}~ww xY w| j                             |¦  «         �Œ)zExecute the events scheduled.Tr   Nz$scheduled task run %s failed: %s: %s)r   r   r   r   r   ÚEMPTY_QUEUE_TIMEOUTr   Úclearr   ÚCLIENT_EXCEPTIONSÚloggerÚwarningÚ	__class__Ú__name__Úwait)r   ÚqÚnowr#   r   Úes         r   ÚrunzScheduler.runB   s�  € àŒKˆð	(Ø”ð 
$ð 
$Ý‘k”k�Ø$%Ð/˜A˜aœD˜D¨4Ð0�4ð 5Ø”y CÒ'Ð'Ý ™
œ
˜
˜
à $¤	¨C¡˜Ø#˜˜à Ô4�EØ”×!Ò!Ñ#Ô#Ð#ð
$ð 
$ð 
$ñ 
$ô 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$øøøð 
$ð 
$ð 
$ð 
$ð ð (Ø”{ð Ø�EðØ—K’K‘M”M�M�MøÝ(ð ð ð Ý—N’NØ>ØœØœÔ,Øñ	ô ð ð ð ð ð ð øøøøðøøøð ”× Ò  Ñ'Ô'Ð'ñ7	(s*   �A%BÂBÂBÂB- Â-
C-Â7,C(Ã(C-N)r   r   )r   r   r   r   r   r
   )r   r   r   r   r   r
   )r,   Ú
__module__Ú__qualname__r   r&   r    r   r1   © r   r   r   r   "   sl   € € € € € ðð ð ð ð
  Ðð+ð +ð +ð +ðð ð ð ð(ð (ð (ð (ð (ð (r   r   )Ú__doc__Ú
__future__r   Úloggingr   r   Úheapqr   r   Útypingr   Úcollections.abcr   Ú_taskr
   Ú_acompatr   r   Ú	getLoggerr,   r)   Ú	Exceptionr(   r   r4   r   r   ú<module>r?      sî   ðð
ð 
ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $à Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ð !Ð !à	ˆÔ	˜8Ñ	$Ô	$€àÐ ð>(ð >(ð >(ð >(ð >(ñ >(ô >(ð >(ð >(ð >(r   