Skip to content

Commit

Permalink
fixed a bug with miner factory not handling ConnectionRefused errors …
Browse files Browse the repository at this point in the history
…properly
  • Loading branch information
UpstreamData committed Jul 19, 2022
1 parent 3ec833e commit b120064
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyasic/API/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async def _x19_multicommand(self, *commands):
except APIError as e:
raise APIError(e)
except Exception as e:
logging.warning(f"{self.ip}: API Multicommand Error: {e.__name__} - {e}")
logging.warning(f"{self.ip}: API Multicommand Error: {e}")
return data

async def send_command(
Expand Down Expand Up @@ -176,7 +176,7 @@ async def send_command(
break
data += d
except Exception as e:
logging.warning(f"{self.ip}: API Command Error: {e.__name__} - {e}")
logging.warning(f"{self.ip}: API Command Error: - {e}")

data = self._load_api_data(data)

Expand Down
4 changes: 2 additions & 2 deletions pyasic/miners/miner_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ async def _get_miner_type(
# catch APIError and let the factory know we cant get data
logging.warning(f"{ip}: API Command Error: {e}")
return None, None, None
except OSError as e:
except OSError or ConnectionRefusedError:
# miner refused connection on API port, we wont be able to get data this way
# try ssh
try:
Expand Down Expand Up @@ -572,7 +572,7 @@ async def _send_api_command(ip: ipaddress.ip_address or str, command: str) -> di
# get reader and writer streams
reader, writer = await asyncio.open_connection(str(ip), 4028)
except OSError as e:
if e.errno in [10061, 22] or e.winerror == 1225:
if e.errno in [10061, 22]:
raise e
logging.warning(f"{str(ip)} - Command {command}: {e}")
return {}
Expand Down

0 comments on commit b120064

Please sign in to comment.