§
    giã
  ã                  ó    — 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
mZ ddlmZ dd	lmZmZ  ej        e¦  «        Z G d
„ d¦  «        ZdS )aß  
A minimal scheduler to schedule tasks to run in the future (async 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)ÚAEventÚALockc                  ó2   — e Zd Zdd„ZdZdd
„Zdd„Zdd„ZdS )ÚAsyncSchedulerÚreturnÚNonec                ó`   — g | _         t          ¦   «         | _        t          ¦   «         | _        d S )N)Ú_queuer   Ú_lockr   Ú_event)Úselfs    úh/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/psycopg_pool/sched_async.pyÚ__init__zAsyncScheduler.__init__   s#   € Ø"$ˆŒÝ‘W”WˆŒ
Ý‘h”hˆŒˆˆó    g     À‚@ÚdelayÚfloatÚactionúCallable[[], Any] | Noner
   c              ƒ  ó`   K  — t          ¦   «         |z   }|                      ||¦  «        ƒ d{V —†S )zpEnter a new task in the queue delayed in the future.

        Schedule a `!None` to stop the execution.
        N)r   Úenterabs)r   r   r   Útimes       r   ÚenterzAsyncScheduler.enter$   s<   è è € õ
 ‰{Œ{˜UÑ"ˆØ—]’] 4¨Ñ0Ô0Ð0Ð0Ð0Ð0Ð0Ð0Ð0r   r   c              ƒ  ó
  K  — t          ||¦  «        }| j        4 ƒd{V —† t          | j        |¦  «         | j        d         |u }ddd¦  «        ƒd{V —† n# 1 ƒd{V —†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.
        Nr   )r
   r   r   r   r   Úset)r   r   r   ÚtaskÚfirsts        r   r   zAsyncScheduler.enterabs,   s  è è € õ
 D˜&Ñ!Ô!ˆØ”:ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ÝT”[ $Ñ'Ô'Ð'Ø”K ”N dÐ*ˆEð	+ð 	+ð 	+ñ 	+ô 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+øøøð 	+ð 	+ð 	+ð 	+ð ð 	ØŒKOŠOÑÔÐàˆs    %AÁ
A!Á$A!c              ƒ  óX  K  — | j         }	 | j        4 ƒd{V —† t          ¦   «         }|r|d         ndx}r(|j        |k    rt	          |¦  «         n|j        |z
  }d}n| j        }| j                             ¦   «          ddd¦  «        ƒd{V —† n# 1 ƒd{V —†swxY w Y   |rh|j        sdS 	 |                     ¦   «         ƒ d{V —† nc# t          $ r6}t                               d|j        |j        j        |¦  «         Y d}~n(d}~ww xY w| j                             |¦  «        ƒ d{V —† Œ!)zExecute the events scheduled.TNr   z$scheduled task run %s failed: %s: %s)r   r   r   r   r   ÚEMPTY_QUEUE_TIMEOUTr   Úclearr   Ú	ExceptionÚloggerÚwarningÚ	__class__Ú__name__Úwait_timeout)r   ÚqÚnowr#   r   Úes         r   ÚrunzAsyncScheduler.run;   s  è è € àŒKˆð	6Ø”zð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$Ý‘k”kØ$%Ð/˜A˜aœD˜D¨4Ð04ð 5Ø”y CÒ'Ð'Ý ™
œ
˜
˜
à $¤	¨C¡˜Ø#˜˜à Ô4EØ”×!Ò!Ñ#Ô#Ð#ð
$ð 
$ð 
$ñ 
$ô 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$ð 
$øøøð 
$ð 
$ð 
$ð 
$ð ð 6Ø”{ð ØEðØŸ+š+™-œ-Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ð'øÝ ð ð ð Ý—N’NØ>ØœØœÔ,Øñ	ô ð ð ð ð ð ð øøøøðøøøð ”k×.Ò.¨uÑ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5Ð5ñ7	6s*   ˜A%BÂ
BÂBÂ,C Ã
DÃ,DÄD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   € € € € € ðð ð ð ð
  Ðð1ð 1ð 1ð 1ðð ð ð ð6ð 6ð 6ð 6ð 6ð 6r   r   )Ú__doc__Ú
__future__r   Úloggingr   r   Úheapqr   r   Útypingr   r   Ú_taskr
   Ú_acompatr   r   Ú	getLoggerr,   r)   r   r4   r   r   ú<module>r=      sÜ   ðð
ð 
ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #à	ˆÔ	˜8Ñ	$Ô	$€ð=6ð =6ð =6ð =6ð =6ñ =6ô =6ð =6ð =6ð =6r   