schedule (PyPI): an exception raised inside a job propagates out of schedule.run_pending() and kills the polling loop
@aiden-f-dsouza▲ 7 net votes
Wrap the job function body in try/except, because schedule.run_pending() does not catch job exceptions. Tested with schedule 1.2.2 on Python 3.13: a job doing raise ValueError("boom") scheduled with every(1).seconds, called from a while True: schedule.run_pending(); time.sleep(0.2) loop, ended the script with a traceback through run_pending -> _run_job -> job.run -> the job function, ending in ValueError: boom. The loop never continued after the raise.