Ejemplo n.º 1
0
def main():
    mainapp = ApplicationService(component='discover', option='')

    mainapp.cache.purge()

    #this is the discovery process
    hosts_list = networkmap(mainapp.configuration.get('discover.dns'), \
        mainapp.configuration.get('discover.minerport'), \
        mainapp.configuration.get('discover.sshport'))
    discoveredentries = findminers(hosts_list, mainapp.knownminers())
    dispatchmessages(mainapp, discoveredentries)
    print('done')
Ejemplo n.º 2
0
    totalpolling = 0
    lop = asyncio.get_event_loop()
    tasks = [
        lop.run_in_executor(cutor, getstats, miner) for miner in listofminers
    ]

    for fut in asyncio.as_completed(tasks, loop=lop):
        results = await fut
        totalpolling += process_result(*results)

    calltime.stop()

    totalms = int(calltime.elapsed() * 1000)
    print('{0} api calls in {1}ms. Avg={2}ms' \
        .format(len(listofminers), totalms, totalms/len(listofminers)))
    timesavings = totalpolling - totalms
    print('Concurrency saved {}ms - {}ms = {}ms ({}%)' \
        .format(totalpolling, totalms, timesavings, int(timesavings/totalpolling*100)))


if __name__ == '__main__':
    MINERS = APP.knownminers()
    APP.print("{0} miners configured".format(len(MINERS)))

    CUTOR = ThreadPoolExecutor(max_workers=WORKER_THREADS)
    LOOP = asyncio.get_event_loop()
    LOOP.run_until_complete(run_tasks(CUTOR, MINERS))
    LOOP.close()
    APP.shutdown()
    #WHATISAID = input('done')