Skip to content

Commit

Permalink
fix: remove task start/end in window_message
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Dec 9, 2024
1 parent cf235db commit bae4782
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions backend/chainlit/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ def emit_call_fn(event: Literal["ask", "call_fn"], data, timeout):
async def connection_successful(sid):
context = init_ws_context(sid)

if context.session.restored:
return

await context.emitter.task_end()
await context.emitter.clear("clear_ask")
await context.emitter.clear("clear_call_fn")

if context.session.restored:
return

if context.session.thread_id_to_resume and config.code.on_chat_resume:
thread = await resume_thread(context.session)
if thread:
Expand Down Expand Up @@ -312,17 +312,13 @@ async def message(sid, payload: MessagePayload):
async def window_message(sid, data):
"""Handle a message send by the host window."""
session = WebsocketSession.require(sid)
context = init_ws_context(session)

await context.emitter.task_start()
init_ws_context(session)

if config.code.on_window_message:
try:
await config.code.on_window_message(data)
except asyncio.CancelledError:
pass
finally:
await context.emitter.task_end()


@sio.on("audio_start")
Expand Down

0 comments on commit bae4782

Please sign in to comment.