Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace async_timeout with asyncio.timeout in python>=3.11 #84

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/rivian/rivian.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import asyncio
import logging
import socket
import sys
import time
import uuid
from collections.abc import Callable
from typing import Any, Type
from warnings import warn

import aiohttp
import async_timeout
from aiohttp import ClientResponse, ClientWebSocketResponse

from .const import LIVE_SESSION_PROPERTIES, VEHICLE_STATE_PROPERTIES, VehicleCommand
Expand All @@ -29,6 +29,11 @@
from .utils import generate_vehicle_command_hmac
from .ws_monitor import WebSocketMonitor

if sys.version_info >= (3, 11):
import asyncio as async_timeout
else:
import async_timeout

_LOGGER = logging.getLogger(__name__)

GRAPHQL_BASEPATH = "https://rivian.com/api/gql"
Expand Down
7 changes: 6 additions & 1 deletion src/rivian/ws_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@

import asyncio
import logging
import sys
from collections.abc import Awaitable, Callable
from datetime import datetime, timezone
from json import loads
from random import uniform
from typing import TYPE_CHECKING, Any
from uuid import uuid4

import async_timeout
from aiohttp import ClientWebSocketResponse, WSMessage, WSMsgType

if sys.version_info >= (3, 11):
import asyncio as async_timeout
else:
import async_timeout

if TYPE_CHECKING:
from .rivian import Rivian

Expand Down