Skip to content

Commit

Permalink
fix shared sessions (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Dec 5, 2023
1 parent 20c95e1 commit e653e4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion livekit-api/livekit/api/_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Service(ABC):
def __init__(
self, host: str, api_key: str, api_secret: str, session: aiohttp.ClientSession
self, session: aiohttp.ClientSession, host: str, api_key: str, api_secret: str
):
self._client = TwirpClient(session, host, "livekit")
self.api_key = api_key
Expand Down
3 changes: 1 addition & 2 deletions livekit-api/livekit/api/_twirp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def __init__(
pkg: str,
prefix: str = DEFAULT_PREFIX,
) -> None:
self._session = aiohttp.ClientSession()

parse_res = urlparse(host)
scheme = parse_res.scheme
if scheme.startswith("ws"):
Expand All @@ -70,6 +68,7 @@ def __init__(
self.host = host.rstrip("/")
self.pkg = pkg
self.prefix = prefix
self._session = session

async def request(
self,
Expand Down
6 changes: 3 additions & 3 deletions livekit-api/livekit/api/livekit_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def __init__(
raise ValueError("api_key and api_secret must be set")

self._session = aiohttp.ClientSession(timeout=timeout)
self._room = RoomService(url, api_key, api_secret, self._session)
self._ingress = IngressService(url, api_key, api_secret, self._session)
self._egress = EgressService(url, api_key, api_secret, self._session)
self._room = RoomService(self._session, url, api_key, api_secret)
self._ingress = IngressService(self._session, url, api_key, api_secret)
self._egress = EgressService(self._session, url, api_key, api_secret)

@property
def room(self):
Expand Down

0 comments on commit e653e4e

Please sign in to comment.