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
Lite: Websocket queueing #5124
Merged
Merged
Lite: Websocket queueing #5124
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
56834c5
Create a Wasm-emulated WebSocket connection and fix @gradio/client to…
whitphx 749c36e
Explicitly set the default response class for the Wasm mode
whitphx a29652f
Merge branch 'main' into websocket-queueing
abidlabs a5c551f
add changeset
gradio-pr-bot 7fe0dad
Merge branch 'main' into websocket-queueing
whitphx 5cdf55d
Fix is_self_origin() to compare only hosts and rename it to is_self_h…
whitphx 4b5b429
Merge branch 'main' into websocket-queueing
whitphx bbd5e02
Fix Blocks.close() to cancel async tasks in the case of Wasm and call…
whitphx 31bf900
Update comment
whitphx 5ee60a7
Hold the asyncio.Task objects and cancel them at `Blocks.close()`
whitphx 9c65c01
Add try-except to handle the case where `events` is not set to `queue…
whitphx e81315e
Merge branch 'main' into websocket-queueing
whitphx 02c1198
Format queueing.py
whitphx File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@gradio/app": minor | ||
"@gradio/client": minor | ||
"@gradio/wasm": minor | ||
"gradio": minor | ||
--- | ||
|
||
feat:Lite: Websocket queueing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export function is_self_origin(url: URL): boolean { | ||
export function is_self_host(url: URL): boolean { | ||
return ( | ||
url.origin === window.location.origin || | ||
url.origin === "http://localhost:7860" // Ref: https://github.com/gradio-app/gradio/blob/v3.32.0/js/app/src/Index.svelte#L194 | ||
url.host === window.location.host || url.host === "localhost:7860" // Ref: https://github.com/gradio-app/gradio/blob/v3.32.0/js/app/src/Index.svelte#L194 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { WorkerProxy } from "@gradio/wasm"; | ||
import { is_self_host } from "./url"; | ||
|
||
/** | ||
* A WebSocket factory that proxies requests to the worker, | ||
* which also falls back to the original WebSocket() for external resource requests. | ||
*/ | ||
|
||
export function wasm_proxied_WebSocket_factory( | ||
worker_proxy: WorkerProxy, | ||
url: URL | ||
): WebSocket { | ||
if (!is_self_host(url)) { | ||
console.debug("Fallback to original WebSocket"); | ||
return new WebSocket(url); | ||
} | ||
|
||
return worker_proxy.openWebSocket(url.pathname) as unknown as WebSocket; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliabid94 Is this comment correct about the purpose of calling the HTTP endpoint
startup-events
? (Ref: #1969)