Skip to content

Commit

Permalink
async_timeout -> asyncio.timeout (#15216)
Browse files Browse the repository at this point in the history
  • Loading branch information
yocalebo authored Dec 16, 2024
1 parent f6e2e26 commit 03fd254
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/middlewared/middlewared/plugins/apps_images/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import aiohttp
import aiohttp.client_exceptions
import async_timeout
import asyncio
import urllib.parse

import aiohttp

from middlewared.service import CallError

from .utils import (
Expand All @@ -22,7 +21,7 @@ async def _api_call(url, options=None, headers=None, mode='get'):
assert mode in ('get', 'head')
response = {'error': None, 'response': {}, 'response_obj': None}
try:
async with async_timeout.timeout(timeout):
async with asyncio.timeout(timeout):
async with aiohttp.ClientSession(
raise_for_status=True, trust_env=True,
) as session:
Expand All @@ -40,7 +39,7 @@ async def _api_call(url, options=None, headers=None, mode='get'):
else:
try:
response['response'] = await req.json()
except aiohttp.client_exceptions.ContentTypeError as e:
except aiohttp.ContentTypeError as e:
# quay.io registry returns malformed content type header which aiohttp fails to parse
# even though the content returned by registry is valid json
response['error'] = f'Unable to parse response: {e}'
Expand Down
4 changes: 1 addition & 3 deletions src/middlewared/middlewared/plugins/disk_/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import time
import json

import async_timeout

from middlewared.api import api_method
from middlewared.api.current import DiskTemperatureAlertsArgs, DiskTemperatureAlertsResult
from middlewared.common.smart.smartctl import SMARTCTL_POWERMODES
Expand Down Expand Up @@ -113,7 +111,7 @@ async def temperatures(self, names, options):

async def temperature(name):
try:
async with async_timeout.timeout(15):
async with asyncio.timeout(15):
return await self.middleware.call('disk.temperature', name, options)
except asyncio.TimeoutError:
return None
Expand Down
3 changes: 1 addition & 2 deletions src/middlewared/middlewared/plugins/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import time

import aiohttp
import async_timeout
import requests

from licenselib.utils import proactive_support_allowed
Expand All @@ -24,7 +23,7 @@

async def post(url, data, timeout=INTERNET_TIMEOUT):
try:
async with async_timeout.timeout(timeout):
async with asyncio.timeout(timeout):
async with aiohttp.ClientSession(
raise_for_status=True, trust_env=True,
) as session:
Expand Down
6 changes: 3 additions & 3 deletions src/middlewared/middlewared/plugins/truecommand/connection.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import aiohttp
import async_timeout
import asyncio
import json

import aiohttp


class TruecommandAPIMixin:

Expand All @@ -16,7 +16,7 @@ async def _post_call(self, options=None, payload=None):
timeout = options.get('timeout', 15)
response = {'error': None, 'response': {}}
try:
async with async_timeout.timeout(timeout):
async with asyncio.timeout(timeout):
async with aiohttp.ClientSession(
raise_for_status=True, trust_env=True,
) as session:
Expand Down

0 comments on commit 03fd254

Please sign in to comment.