added a progress bar when scanning using a generator for scan and get_miner

This commit is contained in:
UpstreamData
2021-12-22 16:46:11 -07:00
parent 66d2b63ae6
commit 06f274ba9c
5 changed files with 72 additions and 9 deletions

View File

@@ -15,6 +15,15 @@ class MinerFactory:
def __init__(self):
self.miners = {}
async def get_miner_generator(self, found_ips):
loop = asyncio.get_event_loop()
scan_tasks = []
for miner in found_ips:
scan_tasks.append(loop.create_task(self.get_miner(miner)))
scanned = asyncio.as_completed(scan_tasks)
for miner in scanned:
yield await miner
async def get_miner(self, ip: ipaddress.ip_address) -> BOSminer or CGMiner or BMMiner or UnknownMiner:
"""Decide a miner type using the IP address of the miner."""
# check if the miner already exists in cache