Skip to content

Commit 55b8d47

Browse files
committed
fix: do not attempt to cache the session, the "async with" will close it anyway
1 parent 395879c commit 55b8d47

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/rmmtxauthz/mediamtx.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Optional, ClassVar, Sequence, Dict, Any
44
import logging
5-
from dataclasses import dataclass, field
5+
from dataclasses import dataclass
66

77
import aiohttp
88

@@ -15,8 +15,6 @@
1515
class MediaMTXControl:
1616
"""MediaMTX control API abstraction"""
1717

18-
_session: Optional[aiohttp.ClientSession] = field(default=None, init=False, repr=False)
19-
2018
_singleton: ClassVar[Optional["MediaMTXControl"]] = None
2119

2220
@classmethod
@@ -28,12 +26,9 @@ def singleton(cls) -> "MediaMTXControl":
2826

2927
def get_session(self) -> aiohttp.ClientSession:
3028
"""Get session"""
31-
if self._session:
32-
return self._session
3329
cnf = RMMTXSettings.singleton()
3430
auth = aiohttp.BasicAuth(login=cnf.api_username, password=cnf.api_password)
35-
self._session = aiohttp.ClientSession(auth=auth, base_url=cnf.api_url, raise_for_status=True)
36-
return self._session
31+
return aiohttp.ClientSession(auth=auth, base_url=cnf.api_url, raise_for_status=True)
3732

3833
async def get_paths(self, insert_credentials: str = "") -> Sequence[Dict[str, Any]]:
3934
"""Get active paths and generate their corresponding urls for each protocol

0 commit comments

Comments
 (0)