Skip to content

Commit

Permalink
Minimal de-loop=loop-ification
Browse files Browse the repository at this point in the history
required for for Python 3.10+
  • Loading branch information
smurfix authored and pquentin committed Jan 4, 2021
1 parent 8930bf2 commit d1051b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tests/aiotest/test_coroutine.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestCoroutine(aiotest.TestCase):
async def test_hello_world(self, loop, config):
result = []
coro = hello_world(config.asyncio, result, 0.001, loop)
await loop.run_aio_coroutine(config.asyncio.ensure_future(coro, loop=loop))
await loop.run_aio_coroutine(config.asyncio.ensure_future(coro))
assert result == ['Hello', 'World']

@pytest.mark.trio
Expand All @@ -37,7 +37,7 @@ async def run_hello_world(self, loop, config):
@pytest.mark.trio
async def test_waiter(self, loop, config):
async def waiter(asyncio, hello_world, result):
fut = asyncio.Future(loop=loop)
fut = asyncio.Future()
loop.call_soon(fut.set_result, "Future")

value = await fut
Expand Down
10 changes: 5 additions & 5 deletions tests/interop/test_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def call_a_ts(self, proc, *args, loop=None):
@pytest.mark.trio
async def test_call_at(self, loop):
async def delay(t):
done = asyncio.Event(loop=loop)
done = asyncio.Event()
loop.call_at(t, done.set)
await done.wait()

Expand Down Expand Up @@ -318,13 +318,13 @@ async def test_trio_asyncio_cancel_out(self, loop):
async def cancelled_asyncio(seen):
seen.flag |= 1
await asyncio.sleep(0.01)
f = asyncio.Future(loop=loop)
f = asyncio.Future()
f.cancel()
return f.result() # raises error

def cancelled_future(seen):
seen.flag |= 1
f = asyncio.Future(loop=loop)
f = asyncio.Future()
f.cancel()
return f # contains error

Expand Down Expand Up @@ -387,7 +387,7 @@ async def in_trio(started, seen):
seen.flag |= 2

async def cancel_asyncio(seen):
started = asyncio.Event(loop=loop)
started = asyncio.Event()
f = asyncio.ensure_future(self.call_a_t(in_trio, started, seen, loop=loop))
await started.wait()
f.cancel()
Expand Down Expand Up @@ -557,7 +557,7 @@ async def cancel_soon(nursery):
await trio.sleep(0.01)
nursery.cancel_scope.cancel()

hold = asyncio.Event(loop=loop)
hold = asyncio.Event()
seen = Seen()

with test_utils.deprecate(self):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_aio_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class MySubprocessProtocol(asyncio.SubprocessProtocol):
def __init__(self, loop):
self.state = 'INITIAL'
self.transport = None
self.connected = asyncio.Future(loop=loop)
self.completed = asyncio.Future(loop=loop)
self.disconnects = {fd: asyncio.Future(loop=loop) for fd in range(3)}
self.connected = asyncio.Future()
self.completed = asyncio.Future()
self.disconnects = {fd: asyncio.Future() for fd in range(3)}
self.data = {1: b'', 2: b''}
self.returncode = None
self.got_data = {1: asyncio.Event(loop=loop), 2: asyncio.Event(loop=loop)}
self.got_data = {1: asyncio.Event(), 2: asyncio.Event()}

def connection_made(self, transport):
self.transport = transport
Expand Down
2 changes: 1 addition & 1 deletion trio_asyncio/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def abort_cb(raise_cancel_arg):
try:
while True:
# Schedule in asyncio that we read the next item from the iterator
current_read = asyncio.ensure_future(consume_next(), loop=loop)
current_read = asyncio.ensure_future(consume_next())

item = await trio.lowlevel.wait_task_rescheduled(abort_cb)

Expand Down

0 comments on commit d1051b0

Please sign in to comment.