mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-26 01:01:40 +00:00
chore(gateway): replace deprecated asyncio.get_event_loop() with get_running_loop() (#11005)
All 10 call sites in gateway/run.py and gateway/platforms/api_server.py are inside async functions where a loop is guaranteed to be running. get_event_loop() is deprecated since Python 3.10 — it can silently create a new loop when none is running, masking bugs. get_running_loop() raises RuntimeError instead, which is safer. Surfaced during review of PRs #10533 and #10647. Co-authored-by: kshitijk4poor <kshitijk4poor@users.noreply.github.com>
This commit is contained in:
parent
0de6340a73
commit
92a78ffeee
2 changed files with 10 additions and 10 deletions
|
|
@ -902,7 +902,7 @@ class APIServerAdapter(BasePlatformAdapter):
|
|||
return time.monotonic()
|
||||
|
||||
# Stream content chunks as they arrive from the agent
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
while True:
|
||||
try:
|
||||
delta = await loop.run_in_executor(None, lambda: stream_q.get(timeout=0.5))
|
||||
|
|
@ -1241,7 +1241,7 @@ class APIServerAdapter(BasePlatformAdapter):
|
|||
await _emit_text_delta(it)
|
||||
# Other types (non-string, non-tuple) are silently dropped.
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
while True:
|
||||
try:
|
||||
item = await loop.run_in_executor(None, lambda: stream_q.get(timeout=0.5))
|
||||
|
|
@ -2004,7 +2004,7 @@ class APIServerAdapter(BasePlatformAdapter):
|
|||
callers (e.g. the SSE writer) to call ``agent.interrupt()`` from
|
||||
another thread to stop in-progress LLM calls.
|
||||
"""
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
def _run():
|
||||
agent = self._create_agent(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue