Skip to content

Commit

Permalink
Update _twirp_client.py
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Oct 31, 2023
1 parent 1c8d59c commit cc865e3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions livekit-api/livekit/api/_twirp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

import aiohttp
from google.protobuf.message import Message
from urllib.parse import urlparse

DEFAULT_PREFIX = "/twirp"
DEFAULT_PREFIX = "twirp"


class TwirpError(Exception):
Expand Down Expand Up @@ -52,7 +53,10 @@ class TwirpErrorCode:

class TwirpClient:
def __init__(self, host: str, pkg: str, prefix: str = DEFAULT_PREFIX) -> None:
self.host = host
parse_res = urlparse(host)
path = parse_res.path.strip("/")

Check failure on line 57 in livekit-api/livekit/api/_twirp_client.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F841)

livekit-api/livekit/api/_twirp_client.py:57:9: F841 Local variable `path` is assigned to but never used
host = f"http://{parse_res.netloc}/{parse_res.path}"
self.host = host.rstrip("/")
self.pkg = pkg
self.prefix = prefix
self.session = aiohttp.ClientSession()
Expand All @@ -69,8 +73,8 @@ async def request(
headers["Content-Type"] = "application/protobuf"

serialized_data = data.SerializeToString()
async with self.session.post(
url, headers=headers, data=serialized_data
async with self.session.request(
"post", url, headers=headers, data=serialized_data
) as resp:
if resp.status == 200:
return response_class.FromString(await resp.read())
Expand Down

0 comments on commit cc865e3

Please sign in to comment.