File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Replaced deprecated ``asyncio.iscoroutinefunction `` with its counterpart from ``inspect ``
2+ -- by :user: `layday `.
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ def pytest_fixture_setup(fixturedef): # type: ignore[no-untyped-def]
106106 if inspect .isasyncgenfunction (func ):
107107 # async generator fixture
108108 is_async_gen = True
109- elif asyncio .iscoroutinefunction (func ):
109+ elif inspect .iscoroutinefunction (func ):
110110 # regular async fixture
111111 is_async_gen = False
112112 else :
@@ -216,14 +216,14 @@ def _passthrough_loop_context(
216216
217217def pytest_pycollect_makeitem (collector , name , obj ): # type: ignore[no-untyped-def]
218218 """Fix pytest collecting for coroutines."""
219- if collector .funcnamefilter (name ) and asyncio .iscoroutinefunction (obj ):
219+ if collector .funcnamefilter (name ) and inspect .iscoroutinefunction (obj ):
220220 return list (collector ._genfunctions (name , obj ))
221221
222222
223223def pytest_pyfunc_call (pyfuncitem ): # type: ignore[no-untyped-def]
224224 """Run coroutines in an event loop instead of a normal function call."""
225225 fast = pyfuncitem .config .getoption ("--aiohttp-fast" )
226- if asyncio .iscoroutinefunction (pyfuncitem .function ):
226+ if inspect .iscoroutinefunction (pyfuncitem .function ):
227227 existing_loop = pyfuncitem .funcargs .get (
228228 "proactor_loop"
229229 ) or pyfuncitem .funcargs .get ("loop" , None )
Original file line number Diff line number Diff line change 44import functools
55import hashlib
66import html
7+ import inspect
78import keyword
89import os
910import re
@@ -174,15 +175,17 @@ def __init__(
174175 if expect_handler is None :
175176 expect_handler = _default_expect_handler
176177
177- assert asyncio .iscoroutinefunction (
178- expect_handler
178+ assert inspect .iscoroutinefunction ( expect_handler ) or (
179+ sys . version_info < ( 3 , 14 ) and asyncio . iscoroutinefunction ( expect_handler )
179180 ), f"Coroutine is expected, got { expect_handler !r} "
180181
181182 method = method .upper ()
182183 if not HTTP_METHOD_RE .match (method ):
183184 raise ValueError (f"{ method } is not allowed HTTP method" )
184185
185- if asyncio .iscoroutinefunction (handler ):
186+ if inspect .iscoroutinefunction (handler ) or (
187+ sys .version_info < (3 , 14 ) and asyncio .iscoroutinefunction (handler )
188+ ):
186189 pass
187190 elif isinstance (handler , type ) and issubclass (handler , AbstractView ):
188191 pass
Original file line number Diff line number Diff line change 11"""Async gunicorn worker for aiohttp.web"""
22
33import asyncio
4+ import inspect
45import os
56import re
67import signal
@@ -68,7 +69,9 @@ async def _run(self) -> None:
6869 runner = None
6970 if isinstance (self .wsgi , Application ):
7071 app = self .wsgi
71- elif asyncio .iscoroutinefunction (self .wsgi ):
72+ elif inspect .iscoroutinefunction (self .wsgi ) or (
73+ sys .version_info < (3 , 14 ) and asyncio .iscoroutinefunction (self .wsgi )
74+ ):
7275 wsgi = await self .wsgi ()
7376 if isinstance (wsgi , web .AppRunner ):
7477 runner = wsgi
You can’t perform that action at this time.
0 commit comments