summaryrefslogtreecommitdiff
path: root/examples/misc/reference.py
blob: 0005e1af942660a3dd0dafd12f315a3dab3534d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
Basic example showing how to schedule a callable using a textual reference.
"""

from __future__ import annotations

import os

from apscheduler.schedulers.blocking import BlockingScheduler

if __name__ == '__main__':
    scheduler = BlockingScheduler()
    scheduler.add_job('sys:stdout.write', 'interval', seconds=3, args=['tick\n'])
    print('Press Ctrl+{} to exit'.format('Break' if os.name == 'nt' else 'C'))

    try:
        scheduler.initialize()
    except (KeyboardInterrupt, SystemExit):
        pass