Cron asyncio coroutine cleanup on RuntimeError

NousResearch/hermes-agent · cluster 2138 · cron

Data as of

Nothing open on GitHub. Fix merged in #2317. Check it covers your case.

The short answer

0open issues
0open PRs
5items grouped
Known?
Yes. 5 related items grouped here, 1 issue already closed.
Fix event
A fix was merged to main in PR #2317. Check it covers your case. No release data is tracked.
Tracker
The maintainers' tracker marks this resolved, deciding PR #2317. That is separate from the fix event.
Still open
Nothing open on GitHub.

These items address a bug in the cron component where a coroutine is left unawaited or abandoned when asyncio.run() raises a RuntimeError. The fixes focus on properly closing that coroutine to avoid resource leaks.

Open issues0

No open issues.

Open PRs0

No open pull requests.

Fixes on record

Merged to main. A stamp counts the issues a fix is linked to.

  • #2317 fix(cron): close abandoned coroutine when asyncio.run() raises RuntimeError

    merged to main

    files: cron/scheduler.py

    Show the diff
    • cron/scheduler.py
      @@ -170,11 +170,15 @@ def _deliver_result(job: dict, content: str) -> None:
           )
       
           # Run the async send in a fresh event loop (safe from any thread)
      +    coro = _send_to_platform(platform, pconfig, chat_id, wrapped, thread_id=thread_id)
           try:
      -        result = asyncio.run(_send_to_platform(platform, pconfig, chat_id, wrapped, thread_id=thread_id))
      +        result = asyncio.run(coro)
           except RuntimeError:
      -        # asyncio.run() fails if there's already a running loop in this thread;
      -        # spin up a new thread to avoid that.
      +        # asyncio.run() checks for a running loop before awaiting the coroutine;
      +        # when it raises, the original coro was never started — close it to
      +        # prevent "coroutine was never awaited" RuntimeWarning, then retry in a
      +        # fresh thread that has no running loop.
      +        coro.close()
               import concurrent.futures
               with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:
                   future = pool.submit(asyncio.run, _send_to_platform(platform, pconfig, chat_id, wrapped, thread_id=thread_id))

3 PRs closed without merging

From the close comments: merged via another change 1 · other 2

  • #2142 fix(cron): close unawaited coroutine when asyncio.run() hits RuntimeError · other
  • #2248 fix(cron): close unawaited coroutine when asyncio.run() hits RuntimeError · other
  • #2290 fix(cron): close abandoned coroutine when asyncio.run() raises RuntimeError · merged via another change → #2317
Closed issues · 1
  • Closed#2138fix(cron): unawaited coroutine when asyncio.run() hits RuntimeError
How this cluster was grouped
  • Link evidence (structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
  • Pairwise link density 0.40: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. 1.00 means every pair is linked.

Pick up a Lab task

Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.

Open the Lab

At a glance

Subsystem
cron
Merged PRs
#2317
Closed issues
1
Attempts
3 PRs closed without merging
Fix link checked
21 Mar 2026. This confirmation is old and may be out of date (a revert or reopen would not have invalidated it here); re-verify.

For your agent

The same facts, typed.