Skip to content

Commit 8930bf2

Browse files
smurfixpquentin
authored andcommitted
Python 3.10 drops the "loop" argument from "sleep"
1 parent 8c81bbd commit 8930bf2

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
@@ -7,7 +7,7 @@
77
async def hello_world(asyncio, result, delay, loop):
88
result.append("Hello")
99
# retrieve the event loop from the policy
10-
await asyncio.sleep(delay, loop=loop)
10+
await asyncio.sleep(delay)
1111
result.append('World')
1212
return "."
1313

tests/interop/test_adapter.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,25 @@ async def dly_asyncio_depr(self):
6565
async def dly_asyncio_adapted(self):
6666
if sys.version_info >= (3, 7):
6767
assert sniffio.current_async_library() == "asyncio"
68-
await asyncio.sleep(0.01, loop=self.loop)
68+
await asyncio.sleep(0.01)
6969
self.flag |= 1
7070
return 4
7171

7272
async def dly_asyncio(self, do_test=True):
7373
if do_test and sys.version_info >= (3, 7):
7474
assert sniffio.current_async_library() == "asyncio"
75-
await asyncio.sleep(0.01, loop=self.loop)
75+
await asyncio.sleep(0.01)
7676
self.flag |= 1
7777
return 4
7878

7979
async def iter_asyncio(self, do_test=True):
8080
if do_test and sys.version_info >= (3, 7):
8181
assert sniffio.current_async_library() == "asyncio"
82-
await asyncio.sleep(0.01, loop=self.loop)
82+
await asyncio.sleep(0.01)
8383
yield 1
84-
await asyncio.sleep(0.01, loop=self.loop)
84+
await asyncio.sleep(0.01)
8585
yield 2
86-
await asyncio.sleep(0.01, loop=self.loop)
86+
await asyncio.sleep(0.01)
8787
self.flag |= 1
8888

8989
async def iter_trio(self):
@@ -98,10 +98,10 @@ async def iter_trio(self):
9898

9999
@asynccontextmanager
100100
async def ctx_asyncio(self):
101-
await asyncio.sleep(0.01, loop=self.loop)
101+
await asyncio.sleep(0.01)
102102
self.flag |= 1
103103
yield self
104-
await asyncio.sleep(0.01, loop=self.loop)
104+
await asyncio.sleep(0.01)
105105
self.flag |= 2
106106

107107
@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

@@ -193,7 +193,7 @@ def dly_trio(seen):
193193
@pytest.mark.trio
194194
async def test_trio_asyncio(self, loop):
195195
async def dly_asyncio(seen):
196-
await asyncio.sleep(0.01, loop=loop)
196+
await asyncio.sleep(0.01)
197197
seen.flag |= 1
198198
return 4
199199

@@ -280,7 +280,7 @@ def err_trio_sync():
280280
@pytest.mark.trio
281281
async def test_trio_asyncio_error(self, loop):
282282
async def err_asyncio():
283-
await asyncio.sleep(0.01, loop=loop)
283+
await asyncio.sleep(0.01)
284284
raise RuntimeError("I has an owie")
285285

286286
with pytest.raises(RuntimeError) as err:
@@ -317,7 +317,7 @@ async def cancelled_trio(seen):
317317
async def test_trio_asyncio_cancel_out(self, loop):
318318
async def cancelled_asyncio(seen):
319319
seen.flag |= 1
320-
await asyncio.sleep(0.01, loop=loop)
320+
await asyncio.sleep(0.01)
321321
f = asyncio.Future(loop=loop)
322322
f.cancel()
323323
return f.result() # raises error
@@ -404,7 +404,7 @@ async def test_trio_asyncio_cancel_in(self, loop):
404404
async def in_asyncio(started, seen):
405405
started.set()
406406
try:
407-
await asyncio.sleep(9999, loop=loop)
407+
await asyncio.sleep(9999)
408408
except asyncio.CancelledError:
409409
seen.flag |= 1
410410
except trio.Cancelled:
@@ -527,7 +527,7 @@ def err_asyncio():
527527
async def test_trio_asyncio_generator(self, loop):
528528
async def dly_asyncio():
529529
yield 1
530-
await asyncio.sleep(0.01, loop=loop)
530+
await asyncio.sleep(0.01)
531531
yield 2
532532

533533
with test_utils.deprecate(self):
@@ -571,7 +571,7 @@ async def cancel_soon(nursery):
571571
async def test_trio_asyncio_iterator(self, loop):
572572
async def slow_nums():
573573
for n in range(1, 6):
574-
await asyncio.sleep(0.01, loop=loop)
574+
await asyncio.sleep(0.01)
575575
yield n
576576

577577
sum = 0
@@ -583,7 +583,7 @@ async def slow_nums():
583583
async def test_trio_asyncio_iterator_depr(self, loop):
584584
async def slow_nums():
585585
for n in range(1, 6):
586-
await asyncio.sleep(0.01, loop=loop)
586+
await asyncio.sleep(0.01)
587587
yield n
588588

589589
sum = 0

tests/test_misc.py

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

264264
async def cancel_sleep():
265265
h = loop.call_later(0.2, do_not_run)
266-
await asyncio.sleep(0.1, loop=loop)
266+
await asyncio.sleep(0.1)
267267
h.cancel()
268-
await asyncio.sleep(0.3, loop=loop)
268+
await asyncio.sleep(0.3)
269269

270270
await trio_asyncio.aio_as_trio(cancel_sleep, loop=loop)()
271271
assert owch == 0

trio_asyncio/_adapter.py

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

0 commit comments

Comments
 (0)