-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[WASI] WasiEventLoop to keep Task alive #106633
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5011551
test pollable clock too
pavelsavara 5e260b5
re-generate
pavelsavara 34baea9
JCO sample
pavelsavara 3594b87
- CancellationToken
pavelsavara 5154353
test GC of Pollable->Task
pavelsavara 0e6f86c
WasiEventLoop to keep Pollable->Task alive from GC
pavelsavara f857f36
feedback
pavelsavara 067b88c
more tests
pavelsavara d52387e
comments
pavelsavara 7bedb3b
more testing
pavelsavara 292b908
fix token and test
pavelsavara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.cs
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
2 changes: 1 addition & 1 deletion
2
...ttp/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.clocks.v0_2_1.MonotonicClockInterop.cs
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
2 changes: 1 addition & 1 deletion
2
.../src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.http.v0_2_1.ITypes.cs
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
2 changes: 1 addition & 1 deletion
2
...Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.http.v0_2_1.OutgoingHandlerInterop.cs
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
2 changes: 1 addition & 1 deletion
2
...ystem/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.http.v0_2_1.TypesInterop.cs
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
2 changes: 1 addition & 1 deletion
2
.../System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.io.v0_2_1.ErrorInterop.cs
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
2 changes: 1 addition & 1 deletion
2
...tp/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.io.v0_2_1.IError.cs
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
2 changes: 1 addition & 1 deletion
2
...ttp/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.io.v0_2_1.IPoll.cs
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
2 changes: 1 addition & 1 deletion
2
.../src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.io.v0_2_1.IStreams.cs
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
2 changes: 1 addition & 1 deletion
2
...c/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.io.v0_2_1.PollInterop.cs
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
2 changes: 1 addition & 1 deletion
2
...ystem/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.wasi.io.v0_2_1.StreamsInterop.cs
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
21 changes: 21 additions & 0 deletions
21
...aries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.ps1
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,21 @@ | ||
# Prerequisites: | ||
# powershell | ||
# tar | ||
# [cargo](https://rustup.rs/) | ||
$ProgressPreference = 'SilentlyContinue' | ||
$ErrorActionPreference='Stop' | ||
$scriptpath = $MyInvocation.MyCommand.Path | ||
$dir = Split-Path $scriptpath | ||
|
||
Push-Location $dir | ||
|
||
|
||
cargo install --locked --no-default-features --features csharp --version 0.30.0 wit-bindgen-cli | ||
Invoke-WebRequest -Uri https://github.com/WebAssembly/wasi-http/archive/refs/tags/v0.2.1.tar.gz -OutFile v0.2.1.tar.gz | ||
tar xzf v0.2.1.tar.gz | ||
cp world.wit wasi-http-0.2.1/wit/world.wit | ||
wit-bindgen c-sharp -w wasi-http -r native-aot --internal --skip-support-files wasi-http-0.2.1/wit | ||
rm -r wasi-http-0.2.1 | ||
rm v0.2.1.tar.gz | ||
|
||
Pop-Location |
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
3 changes: 3 additions & 0 deletions
3
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/world.wit
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,3 @@ | ||
world wasi-http { | ||
import outgoing-handler; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.cs
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
2 changes: 1 addition & 1 deletion
2
...stem/Threading/Wasi/WasiPollWorld.wit.imports.wasi.clocks.v0_2_1.MonotonicClockInterop.cs
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
2 changes: 1 addition & 1 deletion
2
...ivate.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.imports.wasi.io.v0_2_1.IPoll.cs
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
2 changes: 1 addition & 1 deletion
2
...CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.imports.wasi.io.v0_2_1.PollInterop.cs
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
21 changes: 21 additions & 0 deletions
21
...ibraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.ps1
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,21 @@ | ||
# Prerequisites: | ||
# powershell | ||
# tar | ||
# [cargo](https://rustup.rs/) | ||
$ProgressPreference = 'SilentlyContinue' | ||
$ErrorActionPreference='Stop' | ||
$scriptpath = $MyInvocation.MyCommand.Path | ||
$dir = Split-Path $scriptpath | ||
|
||
Push-Location $dir | ||
|
||
|
||
cargo install --locked --no-default-features --features csharp --version 0.30.0 wit-bindgen-cli | ||
Invoke-WebRequest -Uri https://github.com/WebAssembly/wasi-http/archive/refs/tags/v0.2.1.tar.gz -OutFile v0.2.1.tar.gz | ||
tar xzf v0.2.1.tar.gz | ||
cp world.wit wasi-http-0.2.1/wit/world.wit | ||
wit-bindgen c-sharp -w wasi-poll -r native-aot --internal --skip-support-files wasi-http-0.2.1/wit | ||
rm -r wasi-http-0.2.1 | ||
rm v0.2.1.tar.gz | ||
|
||
Pop-Location |
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.
Here's my naive attempt at this. I'm sure yours is better, but one thing to make sure of is that we give all tasks a chance to run once any of them have been cancelled (see this comment). I can't tell if your code accounts for this.
FWIW, this is the code I've been using to test
HttpClient
timeouts. It's paired with this server code.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.
My solution will cancel the
Task
synchronously when theCancellationTokenSource.Cancel
is called because of theCancellationTokenRegistration
callback.And that could possibly trigger execution of other synchronous/inline continuations.
It seems to me, that synchronous cancellation is better. And it's enough to pass the test.
I added test similar to yours with some azure endpoint, which is not perfect, but I plan to fix it later.