mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
fix(tests): stop log queue listener to prevent FATAL on 3.11 shutdown
The TestRunConversationSurrogateSanitization test creates a full AIAgent, which starts a QueueListener daemon thread (_monitor) via setup_logging(). On Python 3.11 the daemon can still be mid-loop when the interpreter begins shutdown, and accessing partially-torn-down logging objects produces "FATAL: exception not rethread" at process exit — a non-zero exit code in CI even though every test passed. Add an autouse fixture that calls _reset_queued_handlers() after each test to stop the listener and join its worker thread cleanly.
This commit is contained in:
parent
c44de99854
commit
67d0ab47ef
1 changed files with 18 additions and 0 deletions
|
|
@ -16,6 +16,24 @@ from run_agent import (
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _stop_log_queue_listener():
|
||||
"""Stop the async logging QueueListener after each test.
|
||||
|
||||
AIAgent.__init__ → setup_logging() starts a QueueListener daemon
|
||||
thread (_monitor). On Python 3.11 the daemon can still be mid-loop
|
||||
when the interpreter begins shutdown, and accessing partially-torn-down
|
||||
logging objects produces "FATAL: exception not rethread" at process
|
||||
exit — a non-zero exit code in CI even though every test passed.
|
||||
"""
|
||||
yield
|
||||
try:
|
||||
from hermes_logging import _reset_queued_handlers
|
||||
_reset_queued_handlers()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
class TestSanitizeSurrogates:
|
||||
"""Test the _sanitize_surrogates() helper."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue