summaryrefslogtreecommitdiff
path: root/examples/interval.py
blob: e16596c9a7a8b6f676260d80cbe8b5e796ac02d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
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_interval_job(tick, seconds=3)
    print('Press Ctrl+C to exit')
    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass