Skip to content

Commit

Permalink
fix: linters
Browse files Browse the repository at this point in the history
  • Loading branch information
dvilelaf committed Jun 4, 2024
1 parent 86f3aff commit 17b738e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions operate/services/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion operate/services/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17b738e

Please sign in to comment.