bug: handle edge cases where a missed get_config on bosminer can cause an empty config to be applied to a miner.

This commit is contained in:
Upstream Data
2023-09-12 19:20:48 -06:00
parent 20272d4360
commit 55aa3dd85b

View File

@@ -303,17 +303,12 @@ class BOSMiner(BaseMiner):
The config from `self.config`.
"""
logging.debug(f"{self}: Getting config.")
conn = None
try:
conn = await self._get_ssh_connection()
except ConnectionError:
try:
pools = await self.api.pools()
except APIError:
return self.config
if pools:
self.config = MinerConfig().from_api(pools["POOLS"])
return self.config
conn = None
if conn:
async with conn:
# good ol' BBB compatibility :/
@@ -365,6 +360,8 @@ class BOSMiner(BaseMiner):
async def set_power_limit(self, wattage: int) -> bool:
try:
cfg = await self.get_config()
if cfg is None:
return False
cfg.autotuning_wattage = wattage
await self.send_config(cfg)
except Exception as e: