Skip to content

Commit

Permalink
Merge branch 'staging' into release/8.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheem-opentensor committed Dec 2, 2024
2 parents 6b486fc + 4633866 commit 7ed8cb4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bittensor/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ def ensure_connected(func):
def is_connected(substrate) -> bool:
"""Check if the substrate connection is active."""
sock = substrate.websocket.socket
return (
sock is not None
and sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) == 0
)
try:
sock_opt = sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
return sock is not None and sock_opt == 0
except (OSError, AttributeError):
return False

@retry(
exceptions=ConnectionRefusedError,
Expand Down

0 comments on commit 7ed8cb4

Please sign in to comment.