Skip to content

Commit

Permalink
Merge branch 'staging' into feat/roman/remove-prompt-from-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-opentensor authored Nov 5, 2024
2 parents 20c8ba2 + 43a01a7 commit 858f732
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import asyncio
import ssl
from typing import Optional, Any, Union, TypedDict, Iterable

import aiohttp
import numpy as np
import scalecodec
import typer
from bittensor_wallet import Wallet
from bittensor_wallet.utils import SS58_FORMAT
from numpy.typing import NDArray
Expand Down Expand Up @@ -134,7 +134,13 @@ async def __aenter__(self):
logging.error(
f"<red>Error</red>: Timeout occurred connecting to substrate. Verify your chain and network settings: {self}"
)
raise typer.Exit(code=1)
raise ConnectionError
except (ConnectionRefusedError, ssl.SSLError) as error:
logging.error(
f"<red>Error</red>: Connection refused when connecting to substrate. "
f"Verify your chain and network settings: {self}. Error: {error}"
)
raise ConnectionError

async def __aexit__(self, exc_type, exc_val, exc_tb):
await self.substrate.close()
Expand Down
3 changes: 2 additions & 1 deletion bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import argparse
import copy
import socket
import ssl
from typing import Union, Optional, TypedDict, Any

import numpy as np
Expand Down Expand Up @@ -231,7 +232,7 @@ def _get_substrate(self):
except (AttributeError, TypeError, socket.error, OSError) as e:
logging.warning(f"Error setting timeout: {e}")

except ConnectionRefusedError as error:
except (ConnectionRefusedError, ssl.SSLError) as error:
logging.error(
f"Could not connect to {self.network} network with {self.chain_endpoint} chain endpoint.",
)
Expand Down

0 comments on commit 858f732

Please sign in to comment.