3 \o@sddlZddlZddlmZy ddlZWnek rDddlZYnXddlmZdgZ GdddeddZ de j_ d e j _ d e j _ d e j_ d e j_ eZGd ddZdS)N) namedtuple) monotonic schedulerc@s8eZdZgZddZddZddZddZd d Zd S) EventcCs|j|jf|j|jfkS)N)timepriority)sor /usr/lib64/python3.6/sched.py__eq__'sz Event.__eq__cCs|j|jf|j|jfkS)N)rr)rr r r r __lt__(sz Event.__lt__cCs|j|jf|j|jfkS)N)rr)rr r r r __le__)sz Event.__le__cCs|j|jf|j|jfkS)N)rr)rr r r r __gt__*sz Event.__gt__cCs|j|jf|j|jfkS)N)rr)rr r r r __ge__+sz Event.__ge__N) __name__ __module__ __qualname__ __slots__r r rrrr r r r r%s rz(time, priority, 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.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^eZdZeejfddZfefddZfefddZ ddZ d d Z dd d Z e ddZdS)rcCs g|_tj|_||_||_dS)N)_queue threadingRLock_locktimefunc delayfunc)selfrrr r r __init__<s zscheduler.__init__c Cs@|tkr i}t|||||}|jtj|j|WdQRX|S)N) _sentinelrrheapqheappushr)rrractionargumentkwargseventr r r enterabsDs zscheduler.enterabscCs|j|}|j|||||S)N)rr$)rdelayrr r!r"rr r r enterRs zscheduler.enterc Cs.|j|jj|tj|jWdQRXdS)N)rrremoverheapify)rr#r r r cancel[s zscheduler.cancelc Cs|j |j SQRXdS)N)rr)rr r r emptyfszscheduler.emptyTc Cs|j}|j}|j}|j}tj}x||>|s,P|d\}}} } } |} || krRd} n d} ||WdQRX| r|sx|| S||| q | | | |dq WdS)NrTF)rrrrrheappop)rZblockinglockqrrpoprrr r!r"Znowr%r r r runks* z scheduler.runc Cs:|j|jdd}WdQRXtttj|gt|S)N)rrlistmaprr+len)rZeventsr r r queues zscheduler.queueN)T)rrr_timerZsleeprrr$r&r)r*r/propertyr3r r r r r:s   2)rr collectionsrr ImportErrorZdummy_threadingrr4__all__r__doc__rr r!r"objectrrr r r r s