Skip to content
Snippets Groups Projects

Beekeepy: Add session holder class and session token handling

Merged Krzysztof Mochocki requested to merge kmochocki/beekeepy into develop
Compare and Show latest version
9 files
+ 46
16
Compare changes
  • Side-by-side
  • Inline
Files
9
@@ -3,12 +3,15 @@ from __future__ import annotations
import asyncio
import time
from abc import ABC, abstractmethod
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any
from helpy._communication.settings import CommunicationSettings
from helpy.exceptions import CommunicationError
if TYPE_CHECKING:
from collections.abc import Iterator
from helpy._interfaces.url import HttpUrl
@@ -56,3 +59,9 @@ class AbstractCommunicator(ABC):
if not (ok_status_code_lower_bound <= status_code <= ok_status_code_upper_bound):
raise CommunicationError(f"{status_code=}", f"{sent=}", f"{received=}")
@contextmanager
def restore_settings(self) -> Iterator[None]:
before = self.settings.copy()
yield
self.__settings = before
Loading