From be092f53b624b22a029624ff47c62c2baf358410 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 20 Feb 2025 14:54:32 +0200 Subject: [PATCH] Refactor the logic for the SubtensorInterface.__aenter__ so that it doesn't close the connection after initialisation. --- bittensor_cli/cli.py | 5 +++-- bittensor_cli/src/bittensor/subtensor_interface.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 70ff7bd52..012926c0b 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -3229,10 +3229,11 @@ def stake_remove( ask_for=[WO.NAME, WO.PATH], ) else: - if not hotkey_ss58_address and not wallet_hotkey: + if not hotkey_ss58_address and not wallet_hotkey: hotkey_or_ss58 = Prompt.ask( "Enter the [blue]hotkey[/blue] name or [blue]ss58 address[/blue] to unstake all from [dim](or enter 'all' to unstake from all hotkeys)[/dim]", - default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey, + default=self.config.get("wallet_hotkey") + or defaults.wallet.hotkey, ) else: hotkey_or_ss58 = hotkey_ss58_address or wallet_hotkey diff --git a/bittensor_cli/src/bittensor/subtensor_interface.py b/bittensor_cli/src/bittensor/subtensor_interface.py index ff687fe1b..65474b324 100644 --- a/bittensor_cli/src/bittensor/subtensor_interface.py +++ b/bittensor_cli/src/bittensor/subtensor_interface.py @@ -112,8 +112,8 @@ async def __aenter__(self): f"[yellow]Connecting to Substrate:[/yellow][bold white] {self}..." ): try: - async with self.substrate: - return self + await self.substrate.initialize() + return self except TimeoutError: # TODO verify err_console.print( "\n[red]Error[/red]: Timeout occurred connecting to substrate. "