diff --git a/metadata_backend/api/auth.py b/metadata_backend/api/auth.py index 0777b2ef7..d8e916348 100644 --- a/metadata_backend/api/auth.py +++ b/metadata_backend/api/auth.py @@ -4,7 +4,7 @@ from typing import Any, Optional import aiohttp_session -from aiohttp import web +from aiohttp import ClientTimeout, web from aiohttp.client_exceptions import ClientConnectorError, InvalidURL from aiohttp.web import Request, Response from idpyoidc.client.rp_handler import RPHandler @@ -340,7 +340,7 @@ async def _healtcheck(self) -> dict[str, str]: async with self._client.request( method="GET", url=f"{self.base_url}/.well-known/openid-configuration", - timeout=10, + timeout=ClientTimeout(total=10), ) as response: content = await response.json() LOG.debug("AAI REST API response content is: %r.", content) diff --git a/metadata_backend/server.py b/metadata_backend/server.py index d92d7b39c..5b9349675 100644 --- a/metadata_backend/server.py +++ b/metadata_backend/server.py @@ -51,13 +51,13 @@ async def init( middlewares = [http_error_handler, check_session] if inject_middleware: middlewares = middlewares + inject_middleware - api = web.Application(middlewares=middlewares) + api = web.Application(middlewares=middlewares) # type: ignore sec_key = base64.urlsafe_b64decode(Fernet.generate_key()) session_middleware = aiohttp_session.session_middleware( aiohttp_session.cookie_storage.EncryptedCookieStorage(sec_key) ) - server = web.Application(middlewares=[session_middleware]) + server = web.Application(middlewares=[session_middleware]) # type: ignore metax_handler = MetaxServiceHandler() datacite_handler = DataciteServiceHandler() diff --git a/metadata_backend/services/datacite_service_handler.py b/metadata_backend/services/datacite_service_handler.py index 7c148303b..e911bd339 100644 --- a/metadata_backend/services/datacite_service_handler.py +++ b/metadata_backend/services/datacite_service_handler.py @@ -140,7 +140,7 @@ async def _healtcheck(self) -> dict[str, Any]: async with self._client.request( method="GET", url=f"{self.base_url}/heartbeat", - timeout=10, + timeout=ClientTimeout(total=10), ) as response: content = await response.text() LOG.info("Datacite REST API response content is: %s.", content) diff --git a/metadata_backend/services/metax_service_handler.py b/metadata_backend/services/metax_service_handler.py index f8e4a0b51..f4345d498 100644 --- a/metadata_backend/services/metax_service_handler.py +++ b/metadata_backend/services/metax_service_handler.py @@ -7,7 +7,7 @@ import time from typing import Any -from aiohttp import BasicAuth, web +from aiohttp import BasicAuth, ClientTimeout, web from aiohttp.client_exceptions import ClientConnectorError, InvalidURL from yarl import URL @@ -316,7 +316,7 @@ async def _healtcheck(self) -> dict[str, str]: async with self._client.request( method="GET", url=f"{URL(metax_config['url'])}/watchman/ping/", - timeout=10, + timeout=ClientTimeout(total=10), ) as response: LOG.debug("Metax REST API status is: %s.", response.status) content = await response.text() diff --git a/metadata_backend/services/rems_service_handler.py b/metadata_backend/services/rems_service_handler.py index 4c248766b..c1896fb0e 100644 --- a/metadata_backend/services/rems_service_handler.py +++ b/metadata_backend/services/rems_service_handler.py @@ -15,7 +15,7 @@ import time from typing import Any -from aiohttp import web +from aiohttp import ClientTimeout, web from aiohttp.client_exceptions import ClientConnectorError, InvalidURL from yarl import URL @@ -181,7 +181,7 @@ async def _healtcheck(self) -> dict[str, Any]: async with self._client.request( method="GET", url=f"{self.base_url}/health", - timeout=10, + timeout=ClientTimeout(total=10), ) as response: LOG.debug("REMS REST API status is: %s.", response.status) content = await response.json() diff --git a/metadata_backend/services/service_handler.py b/metadata_backend/services/service_handler.py index 1ba3dd29e..7b5d3a552 100644 --- a/metadata_backend/services/service_handler.py +++ b/metadata_backend/services/service_handler.py @@ -140,7 +140,7 @@ async def _request( url=url, params=params, json=json_data, - timeout=timeout, + timeout=ClientTimeout(total=timeout), ) as response: if not response.ok: content = await response.text() diff --git a/requirements-dev.txt b/requirements-dev.txt index c3dbe0c50..fe265e437 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,7 +6,7 @@ # aiofiles==24.1.0 # via -r requirements-dev.in -aiohttp==3.9.5 +aiohttp==3.10.5 # via # -r requirements.txt # aiohttp-session diff --git a/requirements.txt b/requirements.txt index dea69b7ee..bf1d9f225 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ # # pip-compile requirements.in # -aiohttp==3.9.5 +aiohttp==3.10.5 # via # -r requirements.in # aiohttp-session