Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Source code for irc.schedule
import abc
from tempora import schedule
[docs]
class IScheduler ( metaclass = abc . ABCMeta ):
[docs]
@abc . abstractmethod
def execute_every ( self , period , func ):
"execute func every period"
[docs]
@abc . abstractmethod
def execute_at ( self , when , func ):
"execute func at when"
[docs]
@abc . abstractmethod
def execute_after ( self , delay , func ):
"execute func after delay"
[docs]
@abc . abstractmethod
def run_pending ( self ):
"invoke the functions that are due"
[docs]
class DefaultScheduler ( schedule . InvokeScheduler , IScheduler ):
[docs]
def execute_every ( self , period , func ):
"""
Executes `func` every `period`.
:param `func`: function to execute
:param `period`: `int` in seconds, or `datetime.timedelta`
"""
self . add ( schedule . PeriodicCommand . after ( period , func ))
[docs]
def execute_at ( self , when , func ):
self . add ( schedule . DelayedCommand . at_time ( when , func ))
[docs]
def execute_after ( self , delay , func ):
self . add ( schedule . DelayedCommand . after ( delay , func ))