HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/kombu/asynchronous/__pycache__/timer.cpython-39.pyc
a

X>h
�@s*dZddlmZddlZddlZddlmZddlmZddlm	Z	ddl
mZddl
m
Zdd	l
mZdd
lmZddlmZddlmZejd
kr�ddlmZnddlmZer�ddlmZdZee�ZdZe� ded��Z!e"ed�Z#edd�Z$ed�efdd�Z%e	Gdd�d��Z&Gdd�d�Z'dS)z"Timer scheduling Python callbacks.�)�annotationsN)�
namedtuple)�datetime)�total_ordering)�	monotonic)�time)�
TYPE_CHECKING)�proxy)�wraps)�
get_logger)��	)�ZoneInfo)�
TracebackType)�Entry�Timer�to_timestamp��UTC�pypy_version_info�	scheduled)�eta�priority�entrycCsFt|t�rB|jdur |j|d�}t�|�}t|t��|d�S|S)z^Convert datetime to timestamp.

    If d' is already a timestamp, then that will be used.
    N)�tzinfor)�
isinstancerr�replace�_time�max�EPOCH�
total_seconds)�dZdefault_timezoner�diff�r#�B/usr/local/lib/python3.9/site-packages/kombu/asynchronous/timer.pyr&s

rc@s\eZdZdZesdZddd�Zdd�Zdd	�Zd
d�Z	dd
�Z
edd��Zej
dd��ZdS)rzSchedule Entry.)�fun�args�kwargs�tref�canceled�	_last_run�__weakref__NcCs4||_|pg|_|pi|_t|�|_d|_d|_dS)NF)r%r&r'�weakrefproxyr(r*r))�selfr%r&r'r#r#r$�__init__=s


zEntry.__init__cCs|j|ji|j��S�N)r%r&r'�r-r#r#r$�__call__EszEntry.__call__cCs$zd|j_WntyYn0dS�NT)r(r)�ReferenceErrorr0r#r#r$�cancelHszEntry.cancelcCsd�|jj|j|j�S)Nz<TimerEntry: {}(*{!r}, **{!r}))�formatr%�__name__r&r'r0r#r#r$�__repr__Ns�zEntry.__repr__cCst|�t|�kSr/)�id)r-�otherr#r#r$�__lt__SszEntry.__lt__cCs|jSr/�r)r0r#r#r$�	cancelledVszEntry.cancelledcCs
||_dSr/r;)r-�valuer#r#r$r<Zs)NN)r6�
__module__�__qualname__�__doc__�IS_PYPY�	__slots__r.r1r4r7r:�propertyr<�setterr#r#r#r$r3s

rc@s�eZdZdZeZdZd0dd�Zdd�Zddd	d
d�dd
�Zd1dd�Z	d2dd�Z
d3dd�Zddefdd�Z
defdd�Zejfdd�Zdd�Zdd�Zd d!�Zeeejejfd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zeejfd,d-��Zed.d/��ZdS)4rzAsync timer implementation.NcKs$t|pt�|_|p|j|_g|_dSr/)�float�DEFAULT_MAX_INTERVAL�max_interval�on_error�_queue)r-rGrHr'r#r#r$r.fszTimer.__init__cCs|Sr/r#r0r#r#r$�	__enter__kszTimer.__enter__ztype[BaseException] | NonezBaseException | NonezTracebackType | None�None)�exc_type�exc_val�exc_tb�returncCs|��dSr/)�stop)r-rLrMrNr#r#r$�__exit__nszTimer.__exit__r#rcCs$|sin|}|�|�|||�||�Sr/)�enter_atr)r-rr%r&r'rr#r#r$�call_atvsz
Timer.call_atcCs$|sin|}|�||�|||�|�Sr/)�enter_afterr)r-�secsr%r&r'rr#r#r$�
call_afterzszTimer.call_aftercsP|sin|}���||��t�������fdd��}|�_d�_������S)Ncs��jt�}}|r|�jn�}z�|rr|�krr|�_�|i|��W�jsp�j}|r^�||n�}��|���SW�jsԈj}|r��||n�}��|���n0�js҈j}|r��||n�}��|���0dSr/)r*rr)rT)r&r'�last�nowZlsince�next�r%rrUr-r(r#r$�_reschedules�s&��z+Timer.call_repeatedly.<locals>._reschedules)rr
r%r*rT)r-rUr%r&r'rr[r#rZr$�call_repeatedly~s
zTimer.call_repeatedlyc
Csf|dur|�}t|t�rXzt|�}Wn2tyV}z|�|�s@�WYd}~dSd}~00|�|||�S)z�Enter function into the scheduler.

        Arguments:
        ---------
            entry (~kombu.asynchronous.timer.Entry): Item to enter.
            eta (datetime.datetime): Scheduled time.
            priority (int): Unused.
        N)rrr�	Exception�handle_error�_enter)r-rrrr�excr#r#r$rR�s	

zTimer.enter_atcCs|�||�t|�|�Sr/)rRrE)r-rUrrrr#r#r$rT�szTimer.enter_aftercCs||jt|||��|Sr/)rIr)r-rrr�pushr#r#r$r_�szTimer._enterc
CsNz
|�Wn>tyH}z&|�|�s4tjd|dd�WYd}~n
d}~00dS)NzError in timer: %rT)�exc_info)r]r^�logger�error)r-rr`r#r#r$�apply_entry�s


zTimer.apply_entrycCs|jr|�|�dSdSr2)rH)r-rbr#r#r$r^�s
zTimer.handle_errorcCsdSr/r#r0r#r#r$rP�sz
Timer.stopccs�|j}|j}|r~|d}|�|d}}	||	krF||	||�dfVq�||�}
|
|urr|d}|jsd|fVqq�|||
�qdVqdS)z�Iterate over schedule.

        This iterator yields a tuple of ``(wait_seconds, entry)``,
        where if entry is :const:`None` the caller should wait
        for ``wait_seconds`` until it polls the schedule again.
        rNr)NN)rGrIr))r-�minZnowfun�poprarG�queueZeventArXrZeventBrr#r#r$�__iter__�s
zTimer.__iter__cCsg|jdd�<dSr/)rIr0r#r#r$�clear�szTimer.clearcCs|��dSr/)r4)r-r(r#r#r$r4�szTimer.cancelcCs
t|j�Sr/)�lenrIr0r#r#r$�__len__�sz
Timer.__len__cCsdSr2r#r0r#r#r$�__nonzero__�szTimer.__nonzero__cs&t|j�}�fdd�|gt|�D�S)z%Snapshot of underlying datastructure.csg|]}�|��qSr#r#)�.0�v��_popr#r$�
<listcomp>��zTimer.queue.<locals>.<listcomp>)�listrIrk)r-rq�eventsr#rpr$rh�s
zTimer.queuecCs|Sr/r#r0r#r#r$�schedule�szTimer.schedule)NN)r#Nr)r#Nr)r#Nr)r6r>r?r@rrHr.rJrQrSrVr\rrRrT�heapq�heappushr_rer^rPrf�heappoprirjr4rlrmrCrhrvr#r#r#r$r_s4



�
r)(r@�
__future__rrw�sys�collectionsrr�	functoolsrrrr�typingr�weakrefr	r,Z
vine.utilsr
Z	kombu.logr�version_infoZzoneinforZbackports.zoneinfo�typesr�__all__r6rcrF�
fromtimestampr�hasattrrArrrrr#r#r#r$�<module>s6



+