Skip to content

Commit 07c2df7

Browse files
committed
Add asyncio detection based on get_running_loop
1 parent 0cfdab8 commit 07c2df7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sniffio/_impl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ async def generic_sleep(seconds):
7474
# Need to sniff for asyncio
7575
if "asyncio" in sys.modules:
7676
import asyncio
77+
try:
78+
asyncio.get_running_loop()
79+
return "asyncio"
80+
except (AttributeError, RuntimeError):
81+
pass
82+
7783
try:
7884
current_task = asyncio.current_task # type: ignore[attr-defined]
7985
except AttributeError:

0 commit comments

Comments
 (0)