diff --git a/epicsarchiver/channelfinder.py b/epicsarchiver/channelfinder.py index b765615ceddfa7afdf0bf8f36709b19dd61f027f..541f002edcad3101667024b726d37621d3832644 100644 --- a/epicsarchiver/channelfinder.py +++ b/epicsarchiver/channelfinder.py @@ -7,7 +7,6 @@ from itertools import chain from typing import Any import urllib3 -from universalasync import wrap from epicsarchiver.service import ServiceClient @@ -62,7 +61,6 @@ class ChannelFinderRequestError(BaseException): session_info: str -@wrap class ChannelFinder(ServiceClient): """Minimal Channel Finder client. diff --git a/epicsarchiver/service.py b/epicsarchiver/service.py index 7496de75c777db42fa3ca5fd285707fcc31e3cfe..85ecffa416c8128f2176fb79e2d7465726f50056 100644 --- a/epicsarchiver/service.py +++ b/epicsarchiver/service.py @@ -1,20 +1,16 @@ """Module to cover the ServiceClient for doing http calls.""" +import asyncio import logging import urllib.parse from collections.abc import Mapping -from typing import TYPE_CHECKING, Any +from typing import Any from aiohttp import ClientResponse, ClientSession -from universalasync import get_event_loop, wrap - -if TYPE_CHECKING: - import asyncio LOG: logging.Logger = logging.getLogger(__name__) -@wrap class ServiceClient: """An async and sync http service client. @@ -24,30 +20,15 @@ class ServiceClient: def __init__(self, base_url: str) -> None: """Create Service object.""" self.base_url = base_url - self._sessions: dict[asyncio.AbstractEventLoop, ClientSession] = {} - - @property - def session(self) -> ClientSession: - """Get a client session to send requests with. - - Returns: - ClientSession: An asynchronous session. - """ - loop = get_event_loop() - session = self._sessions.get(loop) - if session is not None: - return session - self._sessions[loop] = ClientSession() - return self._sessions[loop] + self.session = ClientSession() async def _close(self) -> None: - for session in self._sessions.values(): - if session is not None: - await session.close() + if self.session is not None: + await self.session.close() def __del__(self) -> None: """Delete method makes sure to close any clients first.""" - loop = get_event_loop() + loop = asyncio.get_event_loop() if loop.is_running(): loop.create_task(self._close()) else: diff --git a/pyproject.toml b/pyproject.toml index a0a901c70f825ee2359c402397c38c1e6ca89cf6..0a7cad69011b457abb575800728189354152d401 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,6 @@ dependencies = [ "pytz", "asyncio", "aiohttp", - "universalasync" ] dynamic = ["version"]