diff --git a/peering_gossip.py b/peering_gossip.py index 6ec3667..24eaf5e 100755 --- a/peering_gossip.py +++ b/peering_gossip.py @@ -39,8 +39,7 @@ async def main(): if args.all is True: ixps = pgossip.load_yaml() - for ixp in ixps["ixps"]: - await pgossip.alice_host(ixp) + await pgossip.process_all_ixps_concurrently(ixps) if options is False: if len(sys.argv) == 1: diff --git a/pgossip/pgossip.py b/pgossip/pgossip.py index f166072..bd4b72d 100644 --- a/pgossip/pgossip.py +++ b/pgossip/pgossip.py @@ -424,3 +424,13 @@ def load_yaml(self): with open("pgossip/config.yaml", "r", encoding="utf8") as file: data = yaml.load(file, Loader=yaml.FullLoader) return data + + async def process_all_ixps_concurrently(self, ixps): + """ + Asynchronously processes each IXP in the provided list concurrently by calling the alice_host method. + + Args: + ixps (dict): A dictionary containing a list of IXPs under the key "ixps". + """ + tasks = [self.alice_host(ixp) for ixp in ixps["ixps"]] + await asyncio.gather(*tasks)