From b120064e80066877ac03081109cbff31f091180d Mon Sep 17 00:00:00 2001 From: UpstreamData <75442874+UpstreamData@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:16:36 -0600 Subject: [PATCH] fixed a bug with miner factory not handling ConnectionRefused errors properly --- pyasic/API/__init__.py | 4 ++-- pyasic/miners/miner_factory.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyasic/API/__init__.py b/pyasic/API/__init__.py index 8dc01f47..02a75e5e 100644 --- a/pyasic/API/__init__.py +++ b/pyasic/API/__init__.py @@ -126,7 +126,7 @@ If you are sure you want to use this command please use API.send_command("{comma 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( @@ -176,7 +176,7 @@ If you are sure you want to use this command please use API.send_command("{comma 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) diff --git a/pyasic/miners/miner_factory.py b/pyasic/miners/miner_factory.py index ec5f2885..84b1b875 100644 --- a/pyasic/miners/miner_factory.py +++ b/pyasic/miners/miner_factory.py @@ -408,7 +408,7 @@ class MinerFactory(metaclass=Singleton): # 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: @@ -572,7 +572,7 @@ class MinerFactory(metaclass=Singleton): # 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 {}