python-trio / python-trio/trio
Enable inspection of `fail_at`/`fail_after` attributes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
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:
- Add a wrapper class that defines
__exit__to raiseTooSlowErrorifcancelled_caught, but otherwise passes__getattr__and__setattr__ontoCancelScope - Add a
fail=Trueparameter toCancelScopethat makes it raiseTooSlowErrorupon being cancelled.
Split out from https://github.com/python-trio/trio/pull/3010#issuecomment-2352619529
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the changes proposed in #3010 and the entry points for fail_at, fail_after, and CancelScope. Compare the wrapper and CancelScope approaches, then verify that fail_at and fail_after expose an inspectable deadline while retaining their TooSlowError behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100