add scheduler.py
This commit is contained in:
+7
-5
@@ -69,11 +69,9 @@ def send_appointment_request(message_queue_name, _contact_list):
|
|||||||
receiver.run()
|
receiver.run()
|
||||||
|
|
||||||
|
|
||||||
def start(contact_list_file):
|
def start_send_requests():
|
||||||
pass
|
print("start send requests")
|
||||||
|
contacts_file_path = '~/Desktop/contact_list_2024-04-06-2.xlsx'
|
||||||
if __name__ == '__main__':
|
|
||||||
contacts_file_path = '~/Desktop/contact_list_2024-04-05-2.xlsx'
|
|
||||||
_contact_list = read_contacts(contacts_file_path)
|
_contact_list = read_contacts(contacts_file_path)
|
||||||
_contact_list_to_book = filter_contacts(_contact_list)
|
_contact_list_to_book = filter_contacts(_contact_list)
|
||||||
_segment_number = 10
|
_segment_number = 10
|
||||||
@@ -87,3 +85,7 @@ if __name__ == '__main__':
|
|||||||
last_thread = _thread1
|
last_thread = _thread1
|
||||||
_thread1.start()
|
_thread1.start()
|
||||||
last_thread.join()
|
last_thread.join()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
start_send_requests()
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
|
||||||
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||||
|
|
||||||
|
from request_sender import start_send_requests
|
||||||
|
|
||||||
|
|
||||||
|
def start_book_appointment():
|
||||||
|
start_send_requests()
|
||||||
|
|
||||||
|
|
||||||
|
def start_check_results_job(sched):
|
||||||
|
sched.add_job(start_book_appointment, 'cron', day_of_week='mon-sat', hour='10',
|
||||||
|
minute='30',
|
||||||
|
misfire_grace_time=10,
|
||||||
|
second='0', timezone='Europe/Paris', max_instances=1, args=[])
|
||||||
|
|
||||||
|
|
||||||
|
def config_and_start_jobs():
|
||||||
|
executors = {
|
||||||
|
'default': ThreadPoolExecutor(30),
|
||||||
|
'processpool': ProcessPoolExecutor(12)
|
||||||
|
}
|
||||||
|
sched = BlockingScheduler(executors=executors)
|
||||||
|
start_check_results_job(sched)
|
||||||
|
sched.print_jobs()
|
||||||
|
sched.start()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
config_and_start_jobs()
|
||||||
Reference in New Issue
Block a user