Skip to content

Commit a0be205

Browse files
committed
Restore basic 3.5 compatibility (for now)
1 parent ae488f7 commit a0be205

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import trio_asyncio
1010
import trio_asyncio.loop as loop_
1111
import inspect
12+
from async_generator import async_generator, yield_
1213

1314
# Hacks for <3.7
1415
if not hasattr(asyncio, 'run'):
@@ -51,10 +52,11 @@ def create_task(coro):
5152

5253

5354
@pytest.fixture
55+
@async_generator
5456
async def loop():
5557
async with trio_asyncio.open_loop() as loop:
5658
try:
57-
yield loop
59+
await yield_( loop)
5860
finally:
5961
await loop.stop().wait()
6062

trio_asyncio/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import warnings
1010
from contextvars import ContextVar
1111
from async_generator import asynccontextmanager
12+
from async_generator import async_generator, yield_
1213

1314
from .handles import Handle, TimerHandle
1415

@@ -252,12 +253,13 @@ def run_iterator(self, aiter):
252253
return run_generator(self, aiter)
253254

254255
@asynccontextmanager
256+
@async_generator
255257
async def wrap_trio_context(self, ctx):
256258
"""Run a Trio context manager from asyncio.
257259
"""
258260
res = await self.run_trio(ctx.__aenter__)
259261
try:
260-
yield res
262+
await yield_(res)
261263
except BaseException as exc:
262264
if not await self.run_trio(ctx.__aexit__, type(exc), exc, exc.__traceback__):
263265
raise

0 commit comments

Comments
 (0)