-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add asyncio/anyio taskgroup support to async111&112 (#241)
* add asyncio/anyio taskgroup support to async111, update contributing.md * add asyncio/anyio taskgroup support to async112
- Loading branch information
Showing
9 changed files
with
148 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# main tests in async111.py | ||
# this only tests anyio.create_task_group in particular | ||
# BASE_LIBRARY anyio | ||
# ASYNCIO_NO_ERROR | ||
# TRIO_NO_ERROR | ||
|
||
|
||
import anyio | ||
|
||
|
||
async def bar(*args): ... | ||
|
||
|
||
async def foo(): | ||
async with anyio.create_task_group() as tg: | ||
with open("") as f: | ||
await tg.start(bar, f) # error: 32, lineno-1, lineno-2, "f", "start" | ||
tg.start_soon(bar, f) # error: 31, lineno-2, lineno-3, "f", "start_soon" | ||
|
||
# create_task does not exist in anyio, but gets errors anyway | ||
tg.create_task(bar(f)) # type: ignore[attr-defined] # error: 31, lineno-5, lineno-6, "f", "create_task" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# main tests in async111.py | ||
# this only tests asyncio.TaskGroup in particular | ||
# BASE_LIBRARY asyncio | ||
# ANYIO_NO_ERROR | ||
# TRIO_NO_ERROR | ||
# TaskGroup introduced in 3.11, we run typechecks with 3.9 | ||
# mypy: disable-error-code=attr-defined | ||
|
||
|
||
import asyncio | ||
|
||
|
||
async def bar(*args): ... | ||
|
||
|
||
async def foo(): | ||
async with asyncio.TaskGroup() as tg: | ||
with open("") as f: | ||
tg.create_task(bar(f)) # error: 31, lineno-1, lineno-2, "f", "create_task" | ||
|
||
# start[_soon] does not exist in asyncio, but gets errors anyway | ||
await tg.start(bar, f) # error: 32, lineno-4, lineno-5, "f", "start" | ||
tg.start_soon(bar, f) # error: 31, lineno-5, lineno-6, "f", "start_soon" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# main tests in async112.py | ||
# this only tests anyio.create_task_group in particular | ||
# BASE_LIBRARY anyio | ||
# ASYNCIO_NO_ERROR | ||
# TRIO_NO_ERROR | ||
|
||
import anyio | ||
|
||
|
||
async def bar(*args): ... | ||
|
||
|
||
async def foo(): | ||
async with anyio.create_task_group() as tg: # error: 15, "tg" | ||
await tg.start_soon(bar()) | ||
|
||
async with anyio.create_task_group() as tg: | ||
await tg.start(bar(tg)) | ||
|
||
async with anyio.create_task_group() as tg: # error: 15, "tg" | ||
tg.start_soon(bar()) | ||
|
||
async with anyio.create_task_group() as tg: | ||
tg.start_soon(bar(tg)) | ||
|
||
# will not trigger on create_task | ||
async with anyio.create_task_group() as tg: | ||
tg.create_task(bar()) # type: ignore[attr-defined] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# main tests in async112.py | ||
# this only tests asyncio.TaskGroup in particular | ||
# BASE_LIBRARY asyncio | ||
# ANYIO_NO_ERROR | ||
# TRIO_NO_ERROR | ||
# TaskGroup introduced in 3.11, we run typechecks with 3.9 | ||
# mypy: disable-error-code=attr-defined | ||
|
||
import asyncio | ||
|
||
|
||
async def bar(*args): ... | ||
|
||
|
||
async def foo(): | ||
async with asyncio.TaskGroup() as tg: # error: 15, "tg" | ||
tg.create_task(bar()) | ||
|
||
async with asyncio.TaskGroup() as tg: | ||
tg.create_task(bar(tg)) | ||
|
||
# will not trigger on start / start_soon | ||
async with asyncio.TaskGroup() as tg: | ||
tg.start(bar()) |