From 1addc93e479dcb97fdfecc74606559d9897217ec Mon Sep 17 00:00:00 2001 From: Mark Beierl Date: Thu, 18 May 2023 15:11:34 -0400 Subject: [PATCH] Making main async The initializers for Helm attempt to schedule tasks in the event loop, but now that we are not starting one explicitly and passing it around, we need to have a loop already started at the time of constructor. By making start() async, there is a running loop, and functions like k8s_helm_conn.py (~ #81) can call asyncio.create_task Change-Id: Ia4bf25bd5060dc27f07e63c7395dae3a88247a0e Signed-off-by: Mark Beierl --- osm_lcm/lcm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osm_lcm/lcm.py b/osm_lcm/lcm.py index 1edc960..2fc479f 100644 --- a/osm_lcm/lcm.py +++ b/osm_lcm/lcm.py @@ -705,9 +705,9 @@ class Lcm: async def kafka_read_ping(self): await asyncio.gather(self.kafka_read(), self.kafka_ping()) - def start(self): + async def start(self): # check RO version - asyncio.run(self.check_RO_version()) + await self.check_RO_version() self.ns = ns.NsLcm(self.msg, self.lcm_tasks, self.main_config) # TODO: modify the rest of classes to use the LcmCfg object instead of dicts @@ -725,7 +725,7 @@ class Lcm: self.msg, self.lcm_tasks, self.main_config.to_dict() ) - asyncio.run(self.kafka_read_ping()) + await self.kafka_read_ping() # TODO # self.logger.debug("Terminating cancelling creation tasks") @@ -844,7 +844,7 @@ if __name__ == "__main__": ) exit(1) lcm = Lcm(config_file) - lcm.start() + asyncio.run(lcm.start()) except (LcmException, getopt.GetoptError) as e: print(str(e), file=sys.stderr) # usage() -- 2.25.1