-
Notifications
You must be signed in to change notification settings - Fork 37
/
SchedulerMod.py
69 lines (49 loc) · 1.29 KB
/
SchedulerMod.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from datetime import datetime, date
import time
import logging
import os.path
import apscheduler
from apscheduler.schedulers.background import BackgroundScheduler
logger = logging.getLogger("hydrosys4."+__name__)
# The "apscheduler." prefix is hard coded
sched = BackgroundScheduler({
'apscheduler.executors.default': {
'class': 'apscheduler.executors.pool:ThreadPoolExecutor',
'max_workers': '25'
},
'apscheduler.executors.processpool': {
'type': 'processpool',
'max_workers': '10'
},
'apscheduler.job_defaults.coalesce': 'true',
'apscheduler.job_defaults.max_instances': '5',
'apscheduler.timezone': 'UTC',
})
def print_job():
global sched
sched.print_jobs()
return True
def start_scheduler():
global sched
sched.start()
return True
def removealljobs():
global sched
for job in sched.get_jobs():
job.remove()
return True
def stop_scheduler():
global sched
if sched.running:
sched.shutdown(wait=False)
return True
def get_next_run_time(jobname):
global sched
for job in sched.get_jobs():
if job.name == jobname:
return True , job.next_run_time
return False, ""
if __name__ == '__main__':
"""
prova funzioni di scheduling
"""