From c79859908b4059f211775f72bde19e5745aba75e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Dec 2022 12:23:10 -1000 Subject: [PATCH 1/2] feat: drop async_timeout requirement for python 3.11+ We now use the built-in asyncio.timeout instead when running on python 3.11+ --- pyproject.toml | 2 +- src/zeroconf/_utils/asyncio.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4cfd22ae1..e0918a9f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ build_command = "pip install poetry && poetry build" [tool.poetry.dependencies] python = "^3.7" -async-timeout = ">=3.0.1" +async-timeout = {version = ">=3.0.0", python = "<3.11"} ifaddr = ">=0.1.7" [tool.poetry.group.dev.dependencies] diff --git a/src/zeroconf/_utils/asyncio.py b/src/zeroconf/_utils/asyncio.py index 3d3b7c110..3a5beb5a0 100644 --- a/src/zeroconf/_utils/asyncio.py +++ b/src/zeroconf/_utils/asyncio.py @@ -23,9 +23,13 @@ import asyncio import concurrent.futures import contextlib +import sys from typing import Any, Awaitable, Coroutine, Optional, Set -import async_timeout +if sys.version_info[:2] < (3, 11): + from async_timeout import timeout as asyncio_timeout +else: + from asyncio import timeout as asyncio_timeout from .._exceptions import EventLoopBlocked from ..const import _LOADED_SYSTEM_TIMEOUT @@ -40,7 +44,7 @@ async def wait_event_or_timeout(event: asyncio.Event, timeout: float) -> None: """Wait for an event or timeout.""" with contextlib.suppress(asyncio.TimeoutError): - async with async_timeout.timeout(timeout): + async with asyncio_timeout(timeout): await event.wait() From 893ff78c53fb3654e502469e20dd734aec47bd7a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Dec 2022 12:23:39 -1000 Subject: [PATCH 2/2] feat: drop async_timeout requirement for python 3.11+ We now use the built-in asyncio.timeout instead when running on python 3.11+ --- poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index a51adab8e..032c4ced4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -227,7 +227,7 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "e1ee5359a3695e10975e06463e681d6cdc3e2a2a7268bca9b44fa025a8e8980b" +content-hash = "1b871ae566e35d2aa05a22a4ff564eaec72807a4c37a012e41f8287831435b74" [metadata.files] async-timeout = [