python-trio / python-trio/trio
CancelScope should ensure that the current task is the same in __enter__() and __exit__()
Open
Nobody has claimed this yet.
cancellation
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
The following snippet runs without errors and it shouldn't:
import trio
async def enter_scope(scope):
scope.__enter__()
async def exit_scope(scope):
scope.__exit__(None, None, None)
async def main():
scope = trio.CancelScope()
async with trio.open_nursery() as nursery:
nursery.start_soon(enter_scope, scope)
async with trio.open_nursery() as nursery:
nursery.start_soon(exit_scope, scope)
trio.run(main)
It should check that the current task in __enter__() and __exit__() are the same.
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 reproducing the provided snippet and then inspect CancelScope.enter() and exit(). The change is complete when entering in one task and exiting in another is rejected, while normal same-task use continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100