Scheduler
AutoControl provides a wrapper around APScheduler for scheduling repetitive automation tasks.
Basic Example
from je_auto_control import SchedulerManager
def my_task():
print("Task executed!")
scheduler.remove_blocking_job(id="my_job")
scheduler.shutdown_blocking_scheduler()
scheduler = SchedulerManager()
scheduler.add_interval_blocking_secondly(function=my_task, id="my_job")
scheduler.start_block_scheduler()
Blocking vs Non-Blocking
Mode |
Description |
|---|---|
Blocking |
|
Non-blocking |
|
Interval Scheduling
Schedule a function to run at fixed intervals:
# Every second
scheduler.add_interval_blocking_secondly(function=my_task, id="job1")
# Every minute
scheduler.add_interval_blocking_minutely(function=my_task, id="job2")
# Every hour
scheduler.add_interval_blocking_hourly(function=my_task, id="job3")
# Every day
scheduler.add_interval_blocking_daily(function=my_task, id="job4")
# Every week
scheduler.add_interval_blocking_weekly(function=my_task, id="job5")
Non-blocking equivalents are available with add_interval_nonblocking_* methods.
Cron Scheduling
scheduler.add_cron_blocking(function=my_task, id="cron_job", hour=9, minute=30)
Removing Jobs
scheduler.remove_blocking_job(id="job1")
scheduler.remove_nonblocking_job(id="job2")
Shutting Down
scheduler.shutdown_blocking_scheduler()
scheduler.shutdown_nonblocking_scheduler()
Tip
See the Scheduler API for the complete API reference.