Skip to content
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

[Serve] Improve handling the websocket server disconnect scenario #42130

Merged
merged 7 commits into from
Jan 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions python/ray/serve/_private/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,19 +1039,24 @@ async def send_request_to_replica(
finally:
if not proxy_asgi_receive_task.done():
proxy_asgi_receive_task.cancel()
else:
# If the server disconnects, status_code is set above from the
# disconnect message. Otherwise the disconnect code comes from
# a client message via the receive interface.
if (
status is None
and proxy_request.request_type == "websocket"
and proxy_asgi_receive_task.exception() is None
):

# If the server disconnects, status_code can be set above from the
# disconnect message. but it is not guaranteed.
# If client disconnects, the disconnect code comes from
# a client message via the receive interface, but is is not guaranteed.
sihanwang41 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix grammar and punctuation

if status is None and proxy_request.request_type == "websocket":
if not proxy_asgi_receive_task.cancelled:
sihanwang41 marked this conversation as resolved.
Show resolved Hide resolved
# The disconnect message is sent from the client.
status = ResponseStatus(
code=str(proxy_asgi_receive_task.result()),
is_error=True,
)
else:
# The server disconnect without sending a disconnect message.
sihanwang41 marked this conversation as resolved.
Show resolved Hide resolved
status = ResponseStatus(
code="1000", # [Sihan] is there a better code for this?
GeneDer marked this conversation as resolved.
Show resolved Hide resolved
is_error=True,
)

del self.asgi_receive_queues[request_id]

Expand Down
Loading