setup context manger for SignalClient and LLMClient

This commit is contained in:
2026-03-09 11:39:02 -04:00
parent f762f12bd2
commit c73aa5c98a
3 changed files with 23 additions and 9 deletions

View File

@@ -4,7 +4,7 @@ from __future__ import annotations
import json
import logging
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Self
import httpx
import websockets.sync.client
@@ -121,6 +121,14 @@ class SignalClient:
else:
self.send(message.source, text)
def __enter__(self) -> Self:
"""Enter the context manager."""
return self
def __exit__(self, *args: object) -> None:
"""Close the HTTP client on exit."""
self.close()
def close(self) -> None:
"""Close the HTTP client."""
self._client.close()