Skip to content

Commit

Permalink
Fixed trio task groups being prematurely set inactive
Browse files Browse the repository at this point in the history
Fixes nedbat#11.
  • Loading branch information
agronholm committed Oct 14, 2018
1 parent a7faacd commit cdfb1c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion anyio/_backends/trio.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ async def create_task_group():
async with trio.open_nursery() as nursery:
tg = TaskGroup(nursery)
await yield_(tg)
tg._active = False
except trio.MultiError as exc:
raise ExceptionGroup(exc.exceptions) from None

tg._active = False


#
# Threads
Expand Down
9 changes: 9 additions & 0 deletions tests/test_taskgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ async def testfunc():
run_func(testfunc)


@pytest.mark.anyio
async def test_spawn_while_running():
async def task_func():
await tg.spawn(sleep, 0)

async with create_task_group() as tg:
await tg.spawn(task_func)


@pytest.mark.anyio
async def test_host_exception():
async def set_result(value):
Expand Down

0 comments on commit cdfb1c1

Please sign in to comment.