-
Notifications
You must be signed in to change notification settings - Fork 1
/
ModianListener.py
39 lines (31 loc) · 1.06 KB
/
ModianListener.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
import asyncio
try:
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except ModuleNotFoundError:
pass
from apscheduler.schedulers.asyncio import AsyncIOScheduler
import modian.Schedule as modianSchedule
from modian.configs.ModianConfig import config
if __name__ == "__main__":
sche = AsyncIOScheduler()
if "dailyInterval"in config and config['dailyInterval'] != 0:
dailyInterval = config['dailyInterval']
else:
dailyInterval = 25
if "pkInterval" in config and config['pkInterval'] != 0:
pkInterval = config['pkInterval']
else:
pkInterval = 30
if "daily" in config:
sche.add_job(modianSchedule.dailySchedule, 'interval',
seconds=dailyInterval, max_instances=3)
if "pk" in config:
sche.add_job(modianSchedule.pkSchedule, 'interval',
seconds=pkInterval, max_instances=3)
sche.start()
try:
loop = asyncio.get_event_loop()
loop.run_forever()
except (KeyboardInterrupt, SystemExit):
loop.stop()