summaryrefslogtreecommitdiff
path: root/examples/threaded.py
blob: b80f36ff0d9c850ba920de3843d59bfa959772d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Basic example showing how the scheduler integrates with the application it's
running alongside with.
"""

from datetime import datetime
import time

from apscheduler.scheduler import Scheduler


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


if __name__ == '__main__':
    scheduler = Scheduler()
    scheduler.add_interval_job(tick, seconds=3)
    print('Press Ctrl+C to exit')
    scheduler.start()

    # This is here to simulate application activity (which keeps the main
    # thread alive).
    while True:
        print('This is the main thread.')
        time.sleep(2)