add scheduler.py
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import logging
|
||||
import sys
|
||||
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
|
||||
|
||||
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||
|
||||
from logs.AppLogging import init_logger
|
||||
from wait_for_sms import start_waiting_sms
|
||||
|
||||
|
||||
def waiting_for_sms_job():
|
||||
start_waiting_sms()
|
||||
|
||||
|
||||
def start_waiting_sms_job(sched):
|
||||
sched.add_job(waiting_for_sms_job, 'cron', day_of_week='mon-sat', hour='20',
|
||||
minute='30',
|
||||
misfire_grace_time=10,
|
||||
second='0', timezone='Europe/Paris', max_instances=1)
|
||||
|
||||
|
||||
def config_and_start_jobs():
|
||||
executors = {
|
||||
'default': ThreadPoolExecutor(30),
|
||||
'processpool': ProcessPoolExecutor(12)
|
||||
}
|
||||
sched = BlockingScheduler(executors=executors)
|
||||
start_waiting_sms_job(sched)
|
||||
sched.print_jobs()
|
||||
sched.start()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_logger()
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||
config_and_start_jobs()
|
||||
Reference in New Issue
Block a user