Warn on `finally: cancel_scope.cancel()`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by reading the existing async102 and async120 rules and the concerns in Trio issue 455. Identify the rule implementation, tests, and documentation locations from those rules. Done means the linter warns for the shown finally/cancel pattern and the rules documentation links to the relevant discussion if appropriate.
Written by the indexing model from the issue text.
Description
Like async102 and async120, this is to address the concerns discussed in https://github.com/python-trio/trio/issues/455. (also: should the rules docs link there?)
with CancelScope() as scope:
try:
... # whatever sync and async code here
finally:
scope.cancel()
# You'd hope this just stops any ongoing work, but it swallows exceptions too!
In most cases the solution is simply to scope.cancel() without the try/finally block - structured concurrency means we reliably clean up on exceptions anyway. For some, the cancel scope is entirely unnecessary, and you could call e.g. recv_chan.close() instead of cancelling.
- Dominant language
- Python
- Stars
- 26
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
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.
More from python-trio/flake8-async
-
rule improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
python-trio/flake8-async#457 · 1 reaction ·
-
new rule
Difficulty 3/5 1-2 days Newbie friendliness 55/100
python-trio/flake8-async#454 · 1 comment ·
-
rule improvement
Difficulty 3/5 1-2 days Newbie friendliness 62/100
python-trio/flake8-async#447 · 5 comments ·
-
good first issue
Difficulty 5/5 Over a week Newbie friendliness 15/100
python-trio/flake8-async#396 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
python-trio/flake8-async#395 · 8 comments ·
All issues in python-trio/flake8-async
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100