mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-09 13:21:42 +00:00
A cron tick can fire while the gateway is tearing down (SIGTERM from `hermes update` / `hermes gateway stop` / systemd restart, or an OOM-kill). Once the interpreter is finalizing, `concurrent.futures` refuses new work with `RuntimeError: cannot schedule new futures after interpreter shutdown` and asyncio's default executor is gone, so the cron delivery and dispatch paths crash the tick and spray a traceback into errors.log on every restart-race. Telegram/live-adapter deliveries surface it as "Telegram send failed: ... cannot schedule new futures after interpreter shutdown". Add `_interpreter_shutting_down()` and consult it at the scheduling sites: - the standalone delivery path (`asyncio.run` + the fresh-pool fallback), - the tick dispatch (`_submit_with_guard` `pool.submit`). When finalizing, skip gracefully with a warning instead of raising; the job stays due and fires on the next healthy tick. The helper also matches the RuntimeError text as a fallback, since the concurrent.futures global flag can be set a hair before `sys.is_finalizing()` flips. Fixes #58720. Also addresses the cron paths in #55924. |
||
|---|---|---|
| .. | ||
| scripts | ||
| __init__.py | ||
| blueprint_catalog.py | ||
| jobs.py | ||
| lifecycle_guard.py | ||
| scheduler.py | ||
| scheduler_provider.py | ||
| suggestion_catalog.py | ||
| suggestions.py | ||