From 17b738e8375bb09b47baf4adf4b197664643babc Mon Sep 17 00:00:00 2001 From: David Vilela Date: Tue, 4 Jun 2024 17:38:21 +0200 Subject: [PATCH] fix: linters --- operate/services/manage.py | 26 +++++++++++++------------- operate/services/protocol.py | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 2f4a623c5..ed8a71c8a 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -26,7 +26,7 @@ from concurrent.futures import ThreadPoolExecutor from pathlib import Path -import aiohttp +import aiohttp # type: ignore from aea.helpers.base import IPFSHash from aea.helpers.logging import setup_logger from autonomy.chain.base import registry_contracts @@ -60,6 +60,17 @@ HTTP_OK = 200 +async def check_service_health() -> bool: + """Check the service health""" + async with aiohttp.ClientSession() as session: + async with session.get("http://localhost:8000/healthcheck") as resp: + status = resp.status + response_json = await resp.json() + return status == HTTP_OK and response_json.get( + "is_transitioning_fast", False + ) + + class ServiceManager: """Service manager.""" @@ -826,17 +837,6 @@ def fund_service( # pylint: disable=too-many-arguments chain_type=service.ledger_config.chain, ) - async def check_service_health( - self, - ) -> bool: - async with aiohttp.ClientSession() as session: - async with session.get("http://localhost:8000/healthcheck") as resp: - status = resp.status - response_json = await resp.json() - return status == HTTP_OK and response_json.get( - "is_transitioning_fast", False - ) - async def funding_job( self, hash: str, @@ -881,7 +881,7 @@ async def healthcheck_job( # Check the service health healthy = await loop.run_in_executor( executor, - self.check_service_health, + check_service_health, ) # Restart the service if the health failed 5 times in a row if not healthy: diff --git a/operate/services/protocol.py b/operate/services/protocol.py index 5853f8516..eeda21904 100644 --- a/operate/services/protocol.py +++ b/operate/services/protocol.py @@ -680,7 +680,7 @@ def swap( # pylint: disable=too-many-arguments,too-many-locals key_file = Path(temp_dir, "key.txt") key_file.write_text(owner_key, encoding="utf-8") owner_crypto = EthereumCrypto(private_key_path=str(key_file)) - owner_cryptos: list[EthereumCrypto] = [owner_crypto] + owner_cryptos: t.List[EthereumCrypto] = [owner_crypto] owners = [ manager.ledger_api.api.to_checksum_address(owner_crypto.address) for owner_crypto in owner_cryptos