-
-
Notifications
You must be signed in to change notification settings - Fork 392
Expand cancellation usability from native trio threads #2392
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
Merged
richardsheridan
merged 34 commits into
python-trio:master
from
richardsheridan:from_thread_check_cancelled
Oct 18, 2023
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
d9d02db
Add tests and stub for thread cancellation and reuse.
richardsheridan 0c0ff10
make from_thread tests pass
richardsheridan 5f86fb2
remove failing tests and untested feature
richardsheridan 5f75c86
refactor system tasks to use messages as well
richardsheridan 7ccf0f7
factor out trio_token checking logic
richardsheridan 6d3b2d6
Add trio.from_thread.check_cancelled api to allow threads to efficien…
richardsheridan 2d911ea
Document trio.from_thread.check_cancelled
richardsheridan bc6c82a
Add Newsfragment
richardsheridan 644b913
Linting and fix docs
richardsheridan b87456f
use cancel_register in _send_message_to_host_task
richardsheridan f6b27b2
Document thread reuse semantics
richardsheridan 2b088cc
test coverage for cancelled host task
richardsheridan 832da41
unnest unprotected_fn
richardsheridan 5a10e9b
flip _send_message_to_host_task.in_trio_thread semantics
richardsheridan a09aa84
Merge branch 'master' into from_thread_check_cancelled
richardsheridan 787d286
Aesthetic refactor of API functions
richardsheridan 881180f
fix typos in docs
richardsheridan c0e11d4
remove extra cvar toggling
richardsheridan 1930cae
Transmute AttributeError to RuntimeError
richardsheridan b02dfe9
type consistency between from_thread_run and from_thread_run_sync
richardsheridan 1bb9b79
split up nonblocking send of message from blocking reception of response
richardsheridan 689d45c
thread messages do not necessarily have RetT
richardsheridan c1990d4
Update docs based on review comments
richardsheridan d4d10bb
Merge remote-tracking branch 'upstream/master' into from_thread_check…
richardsheridan daed7bb
fiddle type completeness
richardsheridan 2be054a
fix test_from_thread_run_during_shutdown
richardsheridan a667a52
apply nits from code review
richardsheridan d6df308
document "extra" checkpoints needed to pick up context
richardsheridan 9f4e79e
add TODOs for future assert_never type cleverness
richardsheridan 0e18c93
implement cancellation semantics suggestions from code review
richardsheridan eab30c4
adjust coverage pragma
richardsheridan 2f79f15
revise and document cancellation semantics
richardsheridan 96e45c5
Apply suggestions from code review
richardsheridan ab092b0
Merge branch 'master' into from_thread_check_cancelled
richardsheridan 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
This file contains hidden or 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 hidden or 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,5 @@ | ||
| If called from a thread spawned by `trio.to_thread.run_sync`, `trio.from_thread.run` and | ||
| `trio.from_thread.run_sync` now reuse the task and cancellation status of the host task; | ||
| this means that context variables and cancel scopes naturally propagate 'through' | ||
| threads spawned by Trio. You can also use `trio.from_thread.check_cancelled` | ||
| to efficiently check for cancellation without reentering the Trio thread. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.