From: Mark Beierl Date: Thu, 18 May 2023 19:11:34 +0000 (-0400) Subject: Making main async X-Git-Tag: release-v14.0-start~9 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=1addc93e479dcb97fdfecc74606559d9897217ec;p=osm%2FLCM.git 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 --- diff --git a/osm_lcm/lcm.py b/osm_lcm/lcm.py index 1edc9600..2fc479fe 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()