U vi@sddlmZddlmZmZmZddlmZmZddlmZmZddl m Z ddl m Z ddl mZedZGd d d ejZd S) )abstractmethod)datetime timedeltatimezone)OptionalTypeVar)abctyping) Disposable default_now)UTC_ZERO_TStatec@seZdZdZeedddZedej e e e ej dddZ edejej e e e ej d d d Zedejej e e e ej d d d Zdej e e e ej dddZeejedddZeejedddZeejedddZdS) SchedulerzBase class for the various scheduler implementations in this package as well as the mainloop sub-package. This does not include an implementation of schedule_periodic, refer to PeriodicScheduler. )returncCstS)zRepresents a notion of time for this scheduler. Tasks being scheduled on a scheduler will adhere to the time denoted by this property. Returns: The scheduler's current time, as a datetime instance. r )selfrN/opt/alt/python38/lib/python3.8/site-packages/reactivex/scheduler/scheduler.pynows z Scheduler.nowN)actionstatercCstS)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). NotImplemented)rrrrrrscheduleszScheduler.schedule)duetimerrrcCstS)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). rrrrrrrrschedule_relative0szScheduler.schedule_relativecCstS)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). rrrrrschedule_absoluteEszScheduler.schedule_absolutecCs |||}t|tjr|StS)apInvoke the given given action. This is typically called by instances of ScheduledItem. Args: action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object returned by the action, if any; or a new (no-op) disposable otherwise. ) isinstancerDisposableBaser )rrrretrrr invoke_actionZs  zScheduler.invoke_action)valuercCs(t|tr|t}t|tr$|}|S)aQConverts time value to seconds. This method handles both absolute (datetime) and relative (timedelta) values. If the argument is already a float, it is simply returned unchanged. Args: value: the time value to convert to seconds. Returns: The value converted to seconds. )rrr r total_secondsclsr"rrr to_secondsos  zScheduler.to_secondscCs2t|trt|}nt|ts.tj|tjd}|S)aTConverts time value to datetime. This method handles both absolute (float) and relative (timedelta) values. If the argument is already a datetime, it is simply returned unchanged. Args: value: the time value to convert to datetime. Returns: The value converted to datetime. )tz)rrr r fromtimestamprutcr$rrr to_datetimes   zScheduler.to_datetimecCs,t|tr|t}nt|ts(t|d}|S)aConverts time value to timedelta. This method handles both absolute (datetime) and relative (float) values. If the argument is already a timedelta, it is simply returned unchanged. If the argument is an absolute time, the result value will be the timedelta since the epoch, January 1st, 1970, 00:00:00. Args: value: the time value to convert to timedelta. Returns: The value converted to timedelta. )seconds)rrr rr$rrr to_timedeltas     zScheduler.to_timedelta)N)N)N)N)__name__ __module__ __qualname____doc__propertyrrrrZScheduledActionrrrrr Z RelativeTimerZ AbsoluteTimerr! classmethodZAbsoluteOrRelativeTimefloatr&r*rr,rrrrr sL  rN)rrrrrr rrZ reactivexZreactivex.disposabler Zreactivex.internal.basicr Zreactivex.internal.constantsr rZ SchedulerBaserrrrrs