Esempio n. 1
0
 async def run_parallel_async(self, *tasks):
     future: asyncio.Future = safe_ensure_future(safe_gather(*tasks))
     while not future.done():
         now = time.time()
         next_iteration = now // 1.0 + 1
         await self.clock.run_til(next_iteration)
     return future.result()
def download_erc20_token_addresses():
    try:
        TOKEN_ADDRESS_PATH = "../../wallet/ethereum/erc20_tokens.json"
        logging.getLogger().info(f"Downloading ERC20 token addresses...")

        with open(os.path.join(os.path.dirname(__file__),
                               TOKEN_ADDRESS_PATH)) as old_erc20:
            td = json.load(old_erc20)
            old_len = len(td.keys())
            asyncio.get_event_loop().run_until_complete(
                safe_gather(
                    download_radar_relay_token_addresses(td),
                    download_ddex_token_addresses(td),
                    download_bamboo_relay_token_addresses(td),
                    download_dolomite_token_addresses(td),
                ))
            new_len = len(td.keys())
            with open(
                    os.path.join(os.path.dirname(__file__),
                                 TOKEN_ADDRESS_PATH), "w+") as new_erc20:
                new_erc20.write(json.dumps(td))
                logging.getLogger().info(
                    f"Download Complete: {old_len} - {new_len}")

    except Exception as e:
        logging.getLogger().error(e)
Esempio n. 3
0
 async def run_parallel_async(self, *tasks):
     future: asyncio.Future = safe_ensure_future(safe_gather(*tasks))
     await self.market.start_network()
     while not future.done():
         now = time.time()
         next_iteration = now // 1.0 + 1
         await self._clock.run_til(next_iteration)
         await asyncio.sleep(1.0)
     return future.result()
 async def run_parallel_async(self, *tasks, timeout=None):
     future: asyncio.Future = safe_ensure_future(safe_gather(*tasks))
     timer = 0
     while not future.done():
         if timeout and timer > timeout:
             raise Exception("Time out running parallel async task in tests.")
         timer += 1
         await asyncio.sleep(1.0)
     return future.result()
Esempio n. 5
0
 async def run_parallel_async(*tasks):
     future: asyncio.Future = safe_ensure_future(safe_gather(*tasks))
     while not future.done():
         await asyncio.sleep(1)
     return future.result()