blob: 12ae17f0682179255b103135e7d31ae9ec2fe50e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from __future__ import annotations
import logging
from apscheduler.schedulers.sync import Scheduler
from apscheduler.triggers.interval import IntervalTrigger
from apscheduler.workers.sync import Worker
def say_hello():
print("Hello!")
logging.basicConfig(level=logging.DEBUG)
try:
with Scheduler() as scheduler, Worker(
scheduler.data_store, portal=scheduler.portal
):
scheduler.add_schedule(say_hello, IntervalTrigger(seconds=1))
scheduler.wait_until_stopped()
except (KeyboardInterrupt, SystemExit):
pass
|