o 0i @ s d dl Z d dlZd dlmZ d dlmZ d dlZd dl mZ dgZ eddZ de j _d e j_d e j _de j_de j_d e j_e ZG dd dZdS ) N) namedtuple)count) monotonic schedulerEventz2time, priority, sequence, action, argument, kwargszaNumeric type compatible with the return value of the timefunc function passed to the constructor.zSEvents scheduled for the same time will be executed in the order of their priority.zbA continually increasing sequence number that separates events if time and priority are equal.z?Executing the event means executing action(*argument, **kwargs)zGargument is a sequence holding the positional arguments for the action.zDkwargs is a dictionary holding the keyword arguments for the action.c @ s^ e Zd ZeejfddZdefddZdefddZ dd Z d d Zdd dZe dd ZdS )r c C s* g | _ t | _|| _|| _t | _d S N)_queue threadingRLock_locktimefunc delayfuncr _sequence_generator)selfr r r ,/opt/alt/python310/lib64/python3.10/sched.py__init__5 s zscheduler.__init__r c C s` |t u ri }| j t||t| j|||}t| j| W d |S 1 s)w Y |S r ) _sentinelr r nextr heapqZheappushr )r timepriorityactionargumentkwargseventr r r enterabs> s zscheduler.enterabsc C s | | }| |||||S r )r r )r delayr r r r r r r r enterN s zscheduler.enterc C sF | j | j| t| j W d d S 1 sw Y d S r )r r remover Zheapify)r r r r r cancelW s "zscheduler.cancelc C s4 | j | j W d S 1 sw Y d S r )r r )r r r r emptyb s $zscheduler.emptyTc C s | j }| j}| j}| j}tj} |- |s W d d S |d \}}} } }}| } || kr3d}nd}|| W d n1 sCw Y |rW|sP|| S ||| n| |i | |d q)NTr F)r r r r r heappop)r Zblockinglockqr r popr r sequencer r r Znowr r r r rung s8 z scheduler.runc C sP | j | jd d }W d n1 sw Y tttj|gt| S r )r r listmapr r" len)r Zeventsr r r queue s zscheduler.queueN)T)__name__ __module____qualname___timer sleepr r r r r r! r' propertyr+ r r r r r 3 s 3)r r collectionsr itertoolsr r r r/ __all__r __doc__r r&