Skip to content

Commit a6a6ce6

Browse files
committed
fixes
1 parent c4a4b50 commit a6a6ce6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

livekit-rtc/livekit/rtc/participant.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ async def greet_handler(request_id: str, caller_identity: str, payload: str, res
352352
`register_rpc_method` for more details
353353
"""
354354

355-
def decorator(handler: Callable[[str, str, str, float], Union[Awaitable[str], str]]):
355+
def decorator(
356+
handler: Callable[[str, str, str, float], Union[Awaitable[str], str]],
357+
):
356358
self.register_rpc_method(method, handler)
357359
return handler
358360

@@ -392,10 +394,11 @@ async def _handle_rpc_method_invocation(
392394
else:
393395
try:
394396
if asyncio.iscoroutinefunction(handler):
397+
async_handler = handler # type: Callable[[str, str, str, float], Awaitable[str]]
395398

396399
async def run_handler():
397400
try:
398-
return await handler(
401+
return await async_handler(
399402
request_id, caller_identity, payload, response_timeout
400403
)
401404
except asyncio.CancelledError:
@@ -413,7 +416,8 @@ async def run_handler():
413416
RpcError.ErrorCode.RECIPIENT_DISCONNECTED
414417
)
415418
else:
416-
response_payload = handler(
419+
sync_handler = handler # type: Callable[[str, str, str, float], str]
420+
response_payload = sync_handler(
417421
request_id, caller_identity, payload, response_timeout
418422
)
419423
except RpcError as error:

0 commit comments

Comments
 (0)