mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-30 11:52:04 +00:00
feat(gateway): add AsyncSessionDB offload facade
This commit is contained in:
parent
89daacb454
commit
ea26f22710
1 changed files with 18 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ Key design decisions:
|
|||
- Session source tagging ('cli', 'telegram', 'discord', etc.) for filtering
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import random
|
||||
|
|
@ -5525,3 +5526,20 @@ class SessionDB:
|
|||
(error[:500], session_id),
|
||||
)
|
||||
self._execute_write(_do)
|
||||
|
||||
|
||||
class AsyncSessionDB:
|
||||
"""Async door onto SessionDB: offloads each call via asyncio.to_thread so a blocking SQLite call never freezes the event loop. Generic forwarder — the audit confirms no method returns a live cursor/generator."""
|
||||
|
||||
def __init__(self, db: "SessionDB") -> None:
|
||||
self._db = db
|
||||
|
||||
def __getattr__(self, name: str):
|
||||
attr = getattr(self._db, name)
|
||||
if not callable(attr):
|
||||
return attr
|
||||
|
||||
async def _offloaded(*args, **kwargs):
|
||||
return await asyncio.to_thread(attr, *args, **kwargs)
|
||||
|
||||
return _offloaded
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue