Remove async_timeout backcompat (#65732)
parent
92842b796b
commit
2f46382565
|
@ -1,42 +0,0 @@
|
|||
"""Provide backwards compat for async_timeout."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
import async_timeout
|
||||
|
||||
from .helpers.frame import report
|
||||
|
||||
|
||||
def timeout(
|
||||
delay: float | None, loop: asyncio.AbstractEventLoop | None = None
|
||||
) -> async_timeout.Timeout:
|
||||
"""Backwards compatible timeout context manager that warns with loop usage."""
|
||||
if loop is None:
|
||||
loop = asyncio.get_running_loop()
|
||||
else:
|
||||
report(
|
||||
"called async_timeout.timeout with loop keyword argument. The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.3",
|
||||
error_if_core=False,
|
||||
)
|
||||
if delay is not None:
|
||||
deadline: float | None = loop.time() + delay
|
||||
else:
|
||||
deadline = None
|
||||
return async_timeout.Timeout(deadline, loop)
|
||||
|
||||
|
||||
def current_task(loop: asyncio.AbstractEventLoop) -> asyncio.Task[Any] | None:
|
||||
"""Backwards compatible current_task."""
|
||||
report(
|
||||
"called async_timeout.current_task. The current_task call is deprecated and calls will fail after Home Assistant 2022.3; use asyncio.current_task instead",
|
||||
error_if_core=False,
|
||||
)
|
||||
return asyncio.current_task()
|
||||
|
||||
|
||||
def enable() -> None:
|
||||
"""Enable backwards compat transitions."""
|
||||
async_timeout.timeout = timeout
|
||||
async_timeout.current_task = current_task # type: ignore[attr-defined]
|
|
@ -40,7 +40,7 @@ import attr
|
|||
import voluptuous as vol
|
||||
import yarl
|
||||
|
||||
from . import async_timeout_backcompat, block_async_io, loader, util
|
||||
from . import block_async_io, loader, util
|
||||
from .backports.enum import StrEnum
|
||||
from .const import (
|
||||
ATTR_DOMAIN,
|
||||
|
@ -97,7 +97,6 @@ STAGE_1_SHUTDOWN_TIMEOUT = 100
|
|||
STAGE_2_SHUTDOWN_TIMEOUT = 60
|
||||
STAGE_3_SHUTDOWN_TIMEOUT = 30
|
||||
|
||||
async_timeout_backcompat.enable()
|
||||
block_async_io.enable()
|
||||
|
||||
T = TypeVar("T")
|
||||
|
|
Loading…
Reference in New Issue