File size: 607 Bytes
ef987bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Example usage of the pycron scheduler.

This runnable example demonstrates the core features; see README.md for the
full documentation and additional usage examples.
"""
import time
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from pycron import CronScheduler

if __name__ == "__main__":
    scheduler = CronScheduler()
    counter = {"count": 0}
    scheduler.add_interval_job(0.05, lambda: counter.__setitem__("count", counter["count"] + 1))
    scheduler.start()
    time.sleep(0.18)
    scheduler.stop()
    print(f"executions={counter['count']}")