Skip to content

Commit

Permalink
feat: drop async_timeout requirement for python 3.11+ (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Dec 17, 2022
1 parent 294ea13 commit 1f4224e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -39,7 +39,7 @@ tag_format = "{version}"

[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]
Expand Down
8 changes: 6 additions & 2 deletions src/zeroconf/_utils/asyncio.py
Expand Up @@ -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
Expand All @@ -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()


Expand Down

0 comments on commit 1f4224e

Please sign in to comment.