Skip to content

Commit 1f4224e

Browse files
authored
feat: drop async_timeout requirement for python 3.11+ (#1107)
1 parent 294ea13 commit 1f4224e

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tag_format = "{version}"
3939

4040
[tool.poetry.dependencies]
4141
python = "^3.7"
42-
async-timeout = ">=3.0.1"
42+
async-timeout = {version = ">=3.0.0", python = "<3.11"}
4343
ifaddr = ">=0.1.7"
4444

4545
[tool.poetry.group.dev.dependencies]

src/zeroconf/_utils/asyncio.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
import asyncio
2424
import concurrent.futures
2525
import contextlib
26+
import sys
2627
from typing import Any, Awaitable, Coroutine, Optional, Set
2728

28-
import async_timeout
29+
if sys.version_info[:2] < (3, 11):
30+
from async_timeout import timeout as asyncio_timeout
31+
else:
32+
from asyncio import timeout as asyncio_timeout
2933

3034
from .._exceptions import EventLoopBlocked
3135
from ..const import _LOADED_SYSTEM_TIMEOUT
@@ -40,7 +44,7 @@
4044
async def wait_event_or_timeout(event: asyncio.Event, timeout: float) -> None:
4145
"""Wait for an event or timeout."""
4246
with contextlib.suppress(asyncio.TimeoutError):
43-
async with async_timeout.timeout(timeout):
47+
async with asyncio_timeout(timeout):
4448
await event.wait()
4549

4650

0 commit comments

Comments
 (0)