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

Incorporate TooSlowError into CancelScope #3090

Open
jakkdl opened this issue Sep 19, 2024 · 0 comments
Open

Incorporate TooSlowError into CancelScope #3090

jakkdl opened this issue Sep 19, 2024 · 0 comments

Comments

@jakkdl
Copy link
Member

jakkdl commented Sep 19, 2024

After #3010 we will have the following functionality:

my_move_on_at = move_on_at(5)
assert my_move_on_at.deadline == 5
my_move_on_after = move_on_after(5)
assert my_move_on_after.deadline == 5

# but these return Generator[CancelScope], so you can't inspect/modify the objects
my_fail_at = fail_at(5)
assert my_fail_at.deadline == 5 # AttributeError
my_fail_after = fail_after(5)
assert my_fail_after.deadline == 5 # AttributeError

Since separating initialization & entry has been weird previously the current demand might be low for this functionality, but it might become more common.
The two ways I see of fixing this are:

  1. Add a wrapper class that defines __exit__ to raise TooSlowError if cancelled_caught, but otherwise passes __getattr__ and __setattr__ onto CancelScope
  2. Add a fail=True parameter to CancelScope that makes it raise TooSlowError upon being cancelled.

Split out from #3010 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant