Skip to content

fix(cli): replace get_event_loop() with get_running_loop() to silence RuntimeWarning in process_loop thread#19435

Closed
oluwadareab12 wants to merge 1 commit into
NousResearch:mainfrom
oluwadareab12:fix/process-loop-event-loop-warning
Closed

fix(cli): replace get_event_loop() with get_running_loop() to silence RuntimeWarning in process_loop thread#19435
oluwadareab12 wants to merge 1 commit into
NousResearch:mainfrom
oluwadareab12:fix/process-loop-event-loop-warning

Conversation

@oluwadareab12

Copy link
Copy Markdown
Contributor

Fixes #19285

Root cause: Two calls to asyncio.get_event_loop() (or get_event_loop_policy().get_event_loop()) in cli.py emit a DeprecationWarning on Python 3.10/3.11 and a RuntimeWarning on Python 3.12+ when called from a background thread (e.g. process_loop) that has no current event loop set.

Fix: Replace both calls with asyncio.get_running_loop(), catching RuntimeError when no loop is running. This is the correct modern API -- it returns the running loop if one exists, and raises RuntimeError silently (no warning) otherwise.

Locations changed:

  • _pt_safe_print() (~line 1296): cross-thread print path used by background review, curator, and other bg-thread emissions
  • App startup block (~line 11683): exception handler installation on the app event loop

5 new tests in tests/test_process_loop_event_loop_warning.py, all passing.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] process_loop thread lacks asyncio event loop → RuntimeWarning on startup, harmless but noisy

2 participants