docs(cron): point the disarm comment at _teardown_cron_agent after the helper extraction

This commit is contained in:
kshitijk4poor
2026-09-06 20:08:42 +05:30
committed by kshitij
parent 1256cf52fe
commit fa646582ae
+6 -7
View File
@@ -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: