X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fnotifications.py;h=2e7ba94b1b4790cbf9b5b09190b72d2ddc0b2092;hp=9156c2ce659d15cf586e896be7fe210401f782b9;hb=2c4f9ec63fb977be6df40053be3ea50e409cf97f;hpb=42c84ea6d88ecb94c2a7d2e3e94e86522cbd19aa diff --git a/osm_nbi/notifications.py b/osm_nbi/notifications.py index 9156c2c..2e7ba94 100644 --- a/osm_nbi/notifications.py +++ b/osm_nbi/notifications.py @@ -133,11 +133,13 @@ class NotificationBase: .format(subscriber["subscriptionId"], subscriber["authentication"]["authType"])) - tasks = [] - async with aiohttp.ClientSession(loop=loop) as session: - for notification in notifications: - tasks.append(asyncio.ensure_future(self.send_notification(session, notification, loop=loop), loop=loop)) - await asyncio.gather(*tasks, loop=loop) + if notifications: + tasks = [] + async with aiohttp.ClientSession(loop=loop) as session: + for notification in notifications: + tasks.append(asyncio.ensure_future(self.send_notification(session, notification, loop=loop), + loop=loop)) + await asyncio.gather(*tasks, loop=loop) async def send_notification(self, session: aiohttp.ClientSession, notification: dict, loop: asyncio.AbstractEventLoop = None, retry_count: int = 5, timeout: float = 5.0):