From fa646582ae80eec22d280fdd74e8a99e055334e3 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 6 Sep 2026 20:08:42 +0530 Subject: [PATCH] docs(cron): point the disarm comment at _teardown_cron_agent after the helper extraction --- cron/scheduler.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cron/scheduler.py b/cron/scheduler.py index 4233710b65..c94562fe24 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -1979,13 +1979,12 @@ def _finalize_cron_session(session_db, agent, job_id: str, job_name: str, cron_s logger.debug("Job '%s': session lifecycle classification failed: %s", job_id, e) try: _session_db.end_session(_final_cron_session_id, _end_reason) - # run_job owns cron-session finalization. AIAgent.close() also - # finalizes owned session rows by default; if we release the - # shared SessionDB first and then call agent.close(), that second - # end_session() reopens the just-closed SQLite handle (#94736). - # Once the scheduler has durably booked this terminal reason, - # disarm only the agent's redundant row-finalization step. Its - # remaining resource teardown still runs normally below. + # The scheduler owns cron-session finalization. AIAgent.close() also + # finalizes owned session rows by default; once the shared SessionDB is + # released below, that second end_session() would reopen the just-closed + # SQLite handle (#94736). The reason is durably booked, so disarm only the + # agent's redundant row-finalization; its resource teardown still runs in + # _teardown_cron_agent. if agent is not None: agent._end_session_on_close = False except (Exception, KeyboardInterrupt) as e: