X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fnotifications.py;fp=osm_nbi%2Fnotifications.py;h=63d4ce832f61e21066c30159579efe1eddc5cf45;hp=a62670b6453c2f8e823af95cf38a6ecd8cd62c15;hb=375aeb2647d733ac894b2408f66d36d55217c92d;hpb=9632c1ae3dadb73cf2f8af56e78f1363a977a1e2 diff --git a/osm_nbi/notifications.py b/osm_nbi/notifications.py index a62670b..63d4ce8 100644 --- a/osm_nbi/notifications.py +++ b/osm_nbi/notifications.py @@ -108,12 +108,12 @@ class NotificationBase: return payload async def send_notifications( - self, subscribers: list, loop: asyncio.AbstractEventLoop = None + self, + subscribers: list, ): """ Generate tasks for all notification for an event. :param subscribers: A list of subscribers who want to be notified for event. - :param loop: Event loop object. """ notifications = [] for subscriber in subscribers: @@ -154,21 +154,19 @@ class NotificationBase: if notifications: tasks = [] - async with aiohttp.ClientSession(loop=loop) as session: + async with aiohttp.ClientSession() as session: for notification in notifications: tasks.append( asyncio.ensure_future( - self.send_notification(session, notification, loop=loop), - loop=loop, + self.send_notification(session, notification), ) ) - await asyncio.gather(*tasks, loop=loop) + await asyncio.gather(*tasks) async def send_notification( self, session: aiohttp.ClientSession, notification: dict, - loop: asyncio.AbstractEventLoop = None, retry_count: int = 5, timeout: float = 5.0, ): @@ -177,7 +175,6 @@ class NotificationBase: after maximum number of reties, then notification is dropped. :param session: An aiohttp client session object to maintain http session. :param notification: A dictionary containing all necessary data to make POST request. - :param loop: Event loop object. :param retry_count: An integer specifying the maximum number of reties for a notification. :param timeout: A float representing client timeout of each HTTP request. """ @@ -226,7 +223,7 @@ class NotificationBase: notification["payload"]["subscriptionId"], backoff_delay ) ) - await asyncio.sleep(backoff_delay, loop=loop) + await asyncio.sleep(backoff_delay) # Dropping notification self.logger.debug( "Notification {} sent failed to subscriber:{}.".format(