U vi @sddlmZmZddlmZmZmZddlmZddl m Z mZddl m Z m Z mZddlmZedZGd d d eZd gZd S) )LockTimer)MutableMappingOptionalTypeVar)WeakKeyDictionary)abctyping)CompositeDisposable DisposableSingleAssignmentDisposable)PeriodicScheduler_TStatecseZdZUdZeZeZee dfe d<e ddfdd Z ddddZ dejeeeejd d d Zdejejeeeejd d dZdejejeeeejd ddZZS)TimeoutSchedulerz5A scheduler that schedules work via a timed callback._globalreturnc sPtj@ztj|}Wn*tk r@t|}|tj|<YnXW5QRX|SN)r_lockrKeyErrorsuper__new__)clsself __class__U/opt/alt/python38/lib/python3.8/site-packages/reactivex/scheduler/timeoutscheduler.py singletons zTimeoutScheduler.singletoncCs|Sr)r)rrrrr!szTimeoutScheduler.__new__N)actionstatercsVtddfdd }td|d_ddfdd }tt|S) a!Schedules an action to be executed. Args: action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object used to cancel the scheduled action (best effort). Nrcs_dSrZ invoke_actionZ disposablerr sadrr!rrinterval4sz+TimeoutScheduler.schedule..intervalrTcs dSrcancelrtimerrrdispose;sz*TimeoutScheduler.schedule..dispose)r rdaemonstartr r )rr r!r%r*rr r$rr!r)rschedule$s zTimeoutScheduler.schedule)duetimer r!rcst|}|dkrStddfdd }t||d_ddfdd }tt|S) auSchedules an action to be executed after duetime. Args: duetime: Relative time after which to execute the action. action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object used to cancel the scheduled action (best effort). gNrcs_dSrr"rr#rrr%Xsz4TimeoutScheduler.schedule_relative..intervalTcs dSrr&rr(rrr*_sz3TimeoutScheduler.schedule_relative..dispose)Z to_secondsr.r rr+r,r r )rr/r r!secondsr%r*rr-rschedule_relative@s   z"TimeoutScheduler.schedule_relativecCs||}|||j||S)aoSchedules an action to be executed at duetime. Args: duetime: Absolute time at which to execute the action. action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object used to cancel the scheduled action (best effort). ) to_datetimer1now)rr/r r!rrrschedule_absoluteds z"TimeoutScheduler.schedule_absolute)N)N)N)__name__ __module__ __qualname____doc__rrrrrtype__annotations__ classmethodrrrZScheduledActionrrZDisposableBaser.r Z RelativeTimer1Z AbsoluteTimer4 __classcell__rrrrrs4    (rN) threadingrrr rrrweakrefrZ reactivexrZreactivex.disposabler r r Zperiodicschedulerrrr__all__rrrrs  i