from apscheduler.schedulers.blocking import BlockingScheduler
from dp_event_handler_module import case2_newconfig
import os
def main_func():
scheduler = BlockingScheduler()
scheduler.add_executor('threadpool')
scheduler.add_job(case2_newconfig.process_new_tracking_data, 'interval', seconds=15, id='new_tracking_data')
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
scheduler.print_jobs()
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
I want the scheduler to stop after three iterations of the process_new_tracking_data function. Is there a way of doing this?
ThanksHave you tried stopping the scheduler from the job's target function on the third iteration? Just make sure you use scheduler.shutdown(False) to avoid a deadlock.
If that's no good, you can use an event listener to track job
executions.
--
You received this message because you are subscribed to the Google Groups "APScheduler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.