Skip to content

Commit e775879

Browse files
committed
Python 3.10 drops the "loop" argument from "sleep"
1 parent 9a9f357 commit e775879

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

tests/aiotest/test_coroutine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
async def hello_world(asyncio, result, delay, loop):
77
result.append("Hello")
88
# retrieve the event loop from the policy
9-
await asyncio.sleep(delay, loop=loop)
9+
await asyncio.sleep(delay)
1010
result.append('World')
1111
return "."
1212

tests/interop/test_adapter.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,25 @@ async def dly_trio_adapted(self):
4747
async def dly_asyncio_adapted(self):
4848
if sys.version_info >= (3, 7):
4949
assert sniffio.current_async_library() == "asyncio"
50-
await asyncio.sleep(0.01, loop=self.loop)
50+
await asyncio.sleep(0.01)
5151
self.flag |= 1
5252
return 4
5353

5454
async def dly_asyncio(self, do_test=True):
5555
if do_test and sys.version_info >= (3, 7):
5656
assert sniffio.current_async_library() == "asyncio"
57-
await asyncio.sleep(0.01, loop=self.loop)
57+
await asyncio.sleep(0.01)
5858
self.flag |= 1
5959
return 4
6060

6161
async def iter_asyncio(self, do_test=True):
6262
if do_test and sys.version_info >= (3, 7):
6363
assert sniffio.current_async_library() == "asyncio"
64-
await asyncio.sleep(0.01, loop=self.loop)
64+
await asyncio.sleep(0.01)
6565
yield 1
66-
await asyncio.sleep(0.01, loop=self.loop)
66+
await asyncio.sleep(0.01)
6767
yield 2
68-
await asyncio.sleep(0.01, loop=self.loop)
68+
await asyncio.sleep(0.01)
6969
self.flag |= 1
7070

7171
async def iter_trio(self):
@@ -80,10 +80,10 @@ async def iter_trio(self):
8080

8181
@asynccontextmanager
8282
async def ctx_asyncio(self):
83-
await asyncio.sleep(0.01, loop=self.loop)
83+
await asyncio.sleep(0.01)
8484
self.flag |= 1
8585
yield self
86-
await asyncio.sleep(0.01, loop=self.loop)
86+
await asyncio.sleep(0.01)
8787
self.flag |= 2
8888

8989
@asynccontextmanager

tests/interop/test_calls.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def __aenter__(self):
4848
self.parent.did_it = 1
4949
if sys.version_info >= (3, 7):
5050
assert sniffio.current_async_library() == "asyncio"
51-
await asyncio.sleep(0.01, loop=self.loop)
51+
await asyncio.sleep(0.01)
5252
self.parent.did_it = 2
5353
return self
5454

@@ -131,7 +131,7 @@ def dly_trio(seen):
131131
@pytest.mark.trio
132132
async def test_trio_asyncio(self, loop):
133133
async def dly_asyncio(seen):
134-
await asyncio.sleep(0.01, loop=loop)
134+
await asyncio.sleep(0.01)
135135
seen.flag |= 1
136136
return 4
137137

@@ -163,7 +163,7 @@ def err_trio_sync():
163163
@pytest.mark.trio
164164
async def test_trio_asyncio_error(self, loop):
165165
async def err_asyncio():
166-
await asyncio.sleep(0.01, loop=loop)
166+
await asyncio.sleep(0.01)
167167
raise RuntimeError("I has an owie")
168168

169169
with pytest.raises(RuntimeError) as err:
@@ -190,7 +190,7 @@ async def cancelled_trio(seen):
190190
async def test_trio_asyncio_cancel_out(self, loop):
191191
async def cancelled_asyncio(seen):
192192
seen.flag |= 1
193-
await asyncio.sleep(0.01, loop=loop)
193+
await asyncio.sleep(0.01)
194194
f = asyncio.Future(loop=loop)
195195
f.cancel()
196196
return f.result() # raises error
@@ -247,7 +247,7 @@ async def test_trio_asyncio_cancel_in(self, loop):
247247
async def in_asyncio(started, seen):
248248
started.set()
249249
try:
250-
await asyncio.sleep(9999, loop=loop)
250+
await asyncio.sleep(9999)
251251
except asyncio.CancelledError:
252252
seen.flag |= 1
253253
except trio.Cancelled:
@@ -307,7 +307,7 @@ def err_asyncio():
307307
async def test_trio_asyncio_generator(self, loop):
308308
async def dly_asyncio():
309309
yield 1
310-
await asyncio.sleep(0.01, loop=loop)
310+
await asyncio.sleep(0.01)
311311
yield 2
312312

313313
res = await async_gen_to_list(run_aio_generator(loop, dly_asyncio()))
@@ -348,7 +348,7 @@ async def cancel_soon(nursery):
348348
async def test_trio_asyncio_iterator(self, loop):
349349
async def slow_nums():
350350
for n in range(1, 6):
351-
await asyncio.sleep(0.01, loop=loop)
351+
await asyncio.sleep(0.01)
352352
yield n
353353

354354
sum = 0
@@ -360,7 +360,7 @@ async def slow_nums():
360360
async def test_trio_asyncio_iterator_depr(self, loop):
361361
async def slow_nums():
362362
for n in range(1, 6):
363-
await asyncio.sleep(0.01, loop=loop)
363+
await asyncio.sleep(0.01)
364364
yield n
365365

366366
sum = 0

tests/test_misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def do_not_run():
158158

159159
async def cancel_sleep():
160160
h = loop.call_later(0.2, do_not_run)
161-
await asyncio.sleep(0.1, loop=loop)
161+
await asyncio.sleep(0.1)
162162
h.cancel()
163-
await asyncio.sleep(0.3, loop=loop)
163+
await asyncio.sleep(0.3)
164164

165165
await trio_asyncio.aio_as_trio(cancel_sleep, loop=loop)()
166166
assert owch == 0

trio_asyncio/_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ async def allow_asyncio(fn, *args):
269269
import trio_asyncio
270270
271271
async def hello(loop):
272-
await asyncio.sleep(1, loop=loop)
272+
await asyncio.sleep(1)
273273
print("Hello")
274274
await trio.sleep(1)
275275
print("World")

0 commit comments

Comments
 (0)