8000 Trio102: await inside finally needs shielding and timeout by jakkdl · Pull Request #5 · python-trio/flake8-async · GitHub
[go: up one dir, main page]

Skip to content

Trio102: await inside finally needs shielding and timeout #5

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
merged 13 commits into from
Jul 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added first draft of TRIO102 - awaiting inside finally needs shieldin…
…g and timeout
  • Loading branch information
jakkdl committed Jul 19, 2022
commit 211190a11f3e419954fd03168dba01f79db8fd33
81 changes: 81 additions & 0 deletions tests/trio102.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import trio


async def foo():
try:
pass
finally:
with trio.move_on_after(deadline=30) as s:
s.shield = True
await foo()

try:
pass
finally:
with trio.move_on_after(30) as s:
s.shield = True
await foo()

try:
pass
finally:
await foo() # error

try:
pass
finally:
with trio.move_on_after(30) as s:
await foo() # error

try:
pass
finally:
with trio.move_on_after(30):
await foo() # error

try:
pass
finally:
with trio.move_on_after(30) as s, trio.fail_after(5):
s.shield = True
await foo() # error?

bar = 10

try:
pass
finally:
with trio.move_on_after(bar) as s:
s.shield = True
await foo()

try:
pass
finally:
with trio.move_on_after(bar) as s:
s.shield = False
s.shield = True
await foo()

try:
pass
finally:
with trio.move_on_after(bar) as s:
s.shield = True
await foo()
s.shield = False
await foo() # error
s.shield = True
await foo()

try:
pass
finally:
with open("bar"):
await foo()
with open("bar"):
pass
with trio.move_on_after():
await foo()
with trio.move_on_after(foo=bar):
await foo()
0