Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 27s
Fixes #352 Problem: When the gateway restarts, Python's interpreter enters shutdown phase while the last cron tick is still processing jobs. ThreadPoolExecutor.submit() raises RuntimeError("cannot schedule new futures after interpreter shutdown") for every remaining job. This cascades through the entire tick queue. Fix (two-part): 1. run_job(): Wrap ThreadPoolExecutor creation + submit in try/except. On RuntimeError, fall back to synchronous execution (same thread) so the job at least attempts instead of dying silently. 2. tick(): Check sys.is_finalizing() before each job. If the interpreter is shutting down, stop processing immediately instead of wasting time on doomed ThreadPoolExecutor.submit() calls.