Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions bittensor_cli/src/bittensor/extrinsics/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import time
import typing
from typing import Optional
import subprocess

import backoff
from bittensor_wallet import Wallet
Expand All @@ -35,6 +36,7 @@
millify,
get_human_readable,
print_verbose,
print_error,
)

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -512,12 +514,13 @@ async def get_neuron_for_pubkey_and_subnet():
with console.status(
f":satellite: Checking Account on [bold]subnet:{netuid}[/bold]...",
spinner="aesthetic",
):
) as status:
neuron = await get_neuron_for_pubkey_and_subnet()
if not neuron.is_null:
# bittensor.logging.debug(
# f"Wallet {wallet} is already registered on {neuron.netuid} with {neuron.uid}"
# )
print_error(
f"Wallet {wallet} is already registered on subnet {neuron.netuid} with uid {neuron.uid}",
status,
)
return True

if prompt:
Expand Down Expand Up @@ -611,31 +614,32 @@ async def get_neuron_for_pubkey_and_subnet():
success, err_msg = True, ""
else:
await response.process_events()
if not await response.is_success:
success = await response.is_success
if not success:
success, err_msg = (
False,
format_error_message(
await response.error_message,
substrate=subtensor.substrate,
),
)

if not success:
# Look error here
# https://github.com/opentensor/subtensor/blob/development/pallets/subtensor/src/errors.rs
if "HotKeyAlreadyRegisteredInSubNet" in err_msg:
console.print(
f":white_heavy_check_mark: [green]Already Registered on "
f"[bold]subnet:{netuid}[/bold][/green]"
# Look error here
# https://github.com/opentensor/subtensor/blob/development/pallets/subtensor/src/errors.rs

if "HotKeyAlreadyRegisteredInSubNet" in err_msg:
console.print(
f":white_heavy_check_mark: [green]Already Registered on "
f"[bold]subnet:{netuid}[/bold][/green]"
)
return True
err_console.print(
f":cross_mark: [red]Failed[/red]: {err_msg}"
)
return True

err_console.print(f":cross_mark: [red]Failed[/red]: {err_msg}")
await asyncio.sleep(0.5)
await asyncio.sleep(0.5)

# Successful registration, final check for neuron and pubkey
else:
console.print(":satellite: Checking Balance...")
if success:
console.print(":satellite: Checking Registration status...")
is_registered = await is_hotkey_registered(
subtensor,
netuid=netuid,
Expand Down Expand Up @@ -1231,8 +1235,14 @@ def _terminate_workers_and_wait_for_exit(
if isinstance(worker, Queue_Type):
worker.join_thread()
else:
worker.join()
worker.close()
try:
worker.join(3.0)
except subprocess.TimeoutExpired:
worker.terminate()
try:
worker.close()
except ValueError:
worker.terminate()


# TODO verify this works with async
Expand Down