Skip to content

Commit d1051b0

Browse files
smurfixpquentin
authored andcommitted
Minimal de-loop=loop-ification
required for for Python 3.10+
1 parent 8930bf2 commit d1051b0

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

tests/aiotest/test_coroutine.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TestCoroutine(aiotest.TestCase):
1717
async def test_hello_world(self, loop, config):
1818
result = []
1919
coro = hello_world(config.asyncio, result, 0.001, loop)
20-
await loop.run_aio_coroutine(config.asyncio.ensure_future(coro, loop=loop))
20+
await loop.run_aio_coroutine(config.asyncio.ensure_future(coro))
2121
assert result == ['Hello', 'World']
2222

2323
@pytest.mark.trio
@@ -37,7 +37,7 @@ async def run_hello_world(self, loop, config):
3737
@pytest.mark.trio
3838
async def test_waiter(self, loop, config):
3939
async def waiter(asyncio, hello_world, result):
40-
fut = asyncio.Future(loop=loop)
40+
fut = asyncio.Future()
4141
loop.call_soon(fut.set_result, "Future")
4242

4343
value = await fut

tests/interop/test_calls.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def call_a_ts(self, proc, *args, loop=None):
8383
@pytest.mark.trio
8484
async def test_call_at(self, loop):
8585
async def delay(t):
86-
done = asyncio.Event(loop=loop)
86+
done = asyncio.Event()
8787
loop.call_at(t, done.set)
8888
await done.wait()
8989

@@ -318,13 +318,13 @@ async def test_trio_asyncio_cancel_out(self, loop):
318318
async def cancelled_asyncio(seen):
319319
seen.flag |= 1
320320
await asyncio.sleep(0.01)
321-
f = asyncio.Future(loop=loop)
321+
f = asyncio.Future()
322322
f.cancel()
323323
return f.result() # raises error
324324

325325
def cancelled_future(seen):
326326
seen.flag |= 1
327-
f = asyncio.Future(loop=loop)
327+
f = asyncio.Future()
328328
f.cancel()
329329
return f # contains error
330330

@@ -387,7 +387,7 @@ async def in_trio(started, seen):
387387
seen.flag |= 2
388388

389389
async def cancel_asyncio(seen):
390-
started = asyncio.Event(loop=loop)
390+
started = asyncio.Event()
391391
f = asyncio.ensure_future(self.call_a_t(in_trio, started, seen, loop=loop))
392392
await started.wait()
393393
f.cancel()
@@ -557,7 +557,7 @@ async def cancel_soon(nursery):
557557
await trio.sleep(0.01)
558558
nursery.cancel_scope.cancel()
559559

560-
hold = asyncio.Event(loop=loop)
560+
hold = asyncio.Event()
561561
seen = Seen()
562562

563563
with test_utils.deprecate(self):

tests/test_aio_subprocess.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class MySubprocessProtocol(asyncio.SubprocessProtocol):
2020
def __init__(self, loop):
2121
self.state = 'INITIAL'
2222
self.transport = None
23-
self.connected = asyncio.Future(loop=loop)
24-
self.completed = asyncio.Future(loop=loop)
25-
self.disconnects = {fd: asyncio.Future(loop=loop) for fd in range(3)}
23+
self.connected = asyncio.Future()
24+
self.completed = asyncio.Future()
25+
self.disconnects = {fd: asyncio.Future() for fd in range(3)}
2626
self.data = {1: b'', 2: b''}
2727
self.returncode = None
28-
self.got_data = {1: asyncio.Event(loop=loop), 2: asyncio.Event(loop=loop)}
28+
self.got_data = {1: asyncio.Event(), 2: asyncio.Event()}
2929

3030
def connection_made(self, transport):
3131
self.transport = transport

trio_asyncio/_util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def abort_cb(raise_cancel_arg):
108108
try:
109109
while True:
110110
# Schedule in asyncio that we read the next item from the iterator
111-
current_read = asyncio.ensure_future(consume_next(), loop=loop)
111+
current_read = asyncio.ensure_future(consume_next())
112112

113113
item = await trio.lowlevel.wait_task_rescheduled(abort_cb)
114114

0 commit comments

Comments
 (0)