X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_common%2Fmsglocal.py;h=eba4b97f7928a52773997a6b9f6a75810cbdc8b2;hb=refs%2Fchanges%2F29%2F7129%2F1;hp=1e8e089b22913215ce7835cdab383ccd2a3dce51;hpb=c7ac30d7141ee0a296dc504989731bbf6d8d9a80;p=osm%2Fcommon.git diff --git a/osm_common/msglocal.py b/osm_common/msglocal.py index 1e8e089..eba4b97 100644 --- a/osm_common/msglocal.py +++ b/osm_common/msglocal.py @@ -42,6 +42,7 @@ class MsgLocal(MsgBase): self.files_read = {} self.files_write = {} self.buffer = {} + self.loop = None def connect(self, config): try: @@ -52,6 +53,8 @@ class MsgLocal(MsgBase): self.path += "/" if not os.path.exists(self.path): os.mkdir(self.path) + self.loop = config.get("loop") + except MsgException: raise except Exception as e: # TODO refine @@ -127,6 +130,7 @@ class MsgLocal(MsgBase): :param loop: asyncio loop :return: topic, key, message """ + _loop = loop or self.loop try: while True: msg = self.read(topic, blocks=False) @@ -137,7 +141,7 @@ class MsgLocal(MsgBase): await aiocallback(*msg, **kwargs) else: return msg - await asyncio.sleep(2, loop=loop) + await asyncio.sleep(2, loop=_loop) except MsgException: raise except Exception as e: # TODO refine