Compare commits

...

4 Commits

Author SHA1 Message Date
Upstream Data
e2e1d2f2fd version: bump version number. 2024-05-06 14:43:19 -06:00
Upstream Data
dd205c0f06 feature: use semaphore for scanning. 2024-05-06 14:43:03 -06:00
Upstream Data
79e247c0cf version: bump version number. 2024-05-03 11:19:50 -06:00
Upstream Data
836d045b65 bug: fix bosminer sometimes not being able to set config due to temp settings not being set. 2024-05-03 11:19:33 -06:00
5 changed files with 21 additions and 2 deletions

View File

@@ -38,6 +38,8 @@ class TemperatureConfig(MinerConfigValue):
temp_cfg["hot_temp"] = self.hot
if self.danger is not None:
temp_cfg["dangerous_temp"] = self.danger
if len(temp_cfg) == 0:
return {}
return {"temp_control": temp_cfg}
def as_epic(self) -> dict:
@@ -67,6 +69,7 @@ class TemperatureConfig(MinerConfigValue):
hot=temp_control.get("hot_temp"),
danger=temp_control.get("dangerous_temp"),
)
return cls()
@classmethod
def from_epic(cls, web_conf: dict) -> "TemperatureConfig":

View File

@@ -176,11 +176,14 @@ class BOSMiner(BaseMiner):
self.config = cfg
except toml.TomlDecodeError as e:
raise APIError("Failed to decode toml when getting config.") from e
except TypeError as e:
raise APIError("Failed to decode toml when getting config.") from e
return self.config
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
self.config = config
print(config)
parsed_cfg = config.as_bosminer(user_suffix=user_suffix)
toml_conf = toml.dumps(

View File

@@ -32,6 +32,10 @@ class MinerNetwork:
def __init__(self, hosts: List[ipaddress.IPv4Address]):
self.hosts = hosts
semaphore_limit = settings.get("network_scan_semaphore", 255)
if semaphore_limit is None:
semaphore_limit = 255
self.semaphore = asyncio.Semaphore(semaphore_limit)
def __len__(self):
return len(self.hosts)
@@ -153,8 +157,16 @@ class MinerNetwork:
except TimeoutError:
yield None
async def ping_and_get_miner(
self, ip: ipaddress.ip_address
) -> Union[None, AnyMiner]:
if settings.get("network_scan_semaphore") is None:
return await self._ping_and_get_miner(ip)
async with self.semaphore:
return await self._ping_and_get_miner(ip)
@staticmethod
async def ping_and_get_miner(ip: ipaddress.ip_address) -> Union[None, AnyMiner]:
async def _ping_and_get_miner(ip: ipaddress.ip_address) -> Union[None, AnyMiner]:
try:
return await ping_and_get_miner(ip)
except ConnectionRefusedError:

View File

@@ -24,6 +24,7 @@ from httpx import AsyncHTTPTransport
_settings = { # defaults
"network_ping_retries": 1,
"network_ping_timeout": 3,
"network_scan_semaphore": None,
"factory_get_retries": 1,
"factory_get_timeout": 3,
"get_data_retries": 1,

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyasic"
version = "0.55.1"
version = "0.55.3"
description = "A simplified and standardized interface for Bitcoin ASICs."
authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic"