summaryrefslogtreecommitdiff
path: root/examples/interval.py
blob: 5469fef0f3ae22c0161e1218a1d940b3b3e9e468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
Basic example showing how to start the scheduler and schedule a job that executes on 3 second intervals.
"""

from datetime import datetime

from apscheduler.scheduler import Scheduler


def tick():
    print('Tick! The time is: %s' % datetime.now())


if __name__ == '__main__':
    scheduler = Scheduler(standalone=True)
    scheduler.add_job(tick, 'interval', {'seconds': 3})
    print('Press Ctrl+C to exit')
    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass