-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout context manager should be used inside a task #189
Comments
the same error occured to me. here's my code: @app.route("/api/v1/rtvc/establish", methods=["POST"])
async def establishRealTimeVoiceChat():
if not authenticateSession():
return {'data': 'not authenticated', 'status': False}
if not dProvider.checkIfInitialized():
return {'data': 'not initialized', 'status': False}
charName = ''
try:
data = flask.request.get_json()
charName = data['charName']
except:
return {'data': 'invalid form', 'status': False}
sessionName = uuid.uuid4().hex
session = webFrontend.chatbotManager.VoiceChatSession(sessionName, charName, dProvider)
userName = dProvider.getUserName()
userToken = livekit.api.AccessToken(
webFrontend.config.LIVEKIT_API_KEY, webFrontend.config.LIVEKIT_API_SECRET).with_identity(
'user').with_name(userName).with_grants(livekit.api.VideoGrants(room_join=True, room=sessionName)).to_jwt()
botToken = livekit.api.AccessToken(
webFrontend.config.LIVEKIT_API_KEY, webFrontend.config.LIVEKIT_API_SECRET).with_identity(
'model').with_name(charName).with_grants(livekit.api.VideoGrants(room_join=True, room=sessionName)).to_jwt()
# livekit api is in this file, so we can't put this logic into createRtSession
await livekitApi.room.create_room(create=livekit.api.CreateRoomRequest(name=sessionName, empty_timeout=10*60, max_participants=2)) Update: I came up with a solution. Define a event loop by # livekit api is in this file, so we can't put this logic into createRtSession
async def f():
await livekitApi.room.create_room(create=livekit.api.CreateRoomRequest(name=sessionName, empty_timeout=10*60, max_participants=2))
session.start(botToken)
asyncio.run_coroutine_threadsafe(f(), asyncEventLoop) It took me at least 1 hour to solve it. Update: Fk it. I didn't solve it. However, it just stuck there and refused to create room. I gonna to sleep now. Update: My final solution is to use
Which livekitApi should be initialized in an This explained. |
maybe you can use an asyncio event_loop and using run_until_complete? |
Hello,
I used Livekit Egress API, when I called start_track_composite_egress function. I got the following error :
I used async_to_sync function of asgiref library from django.
Please help me. Thank you.
The text was updated successfully, but these errors were encountered: