From 34fd0d0264a8e0084e2b4987b5170f59796d44f8 Mon Sep 17 00:00:00 2001 From: afonin Date: Sun, 17 Apr 2022 10:29:38 +0300 Subject: [PATCH] Update 'apns2/client.py' - fix backward compatibility --- apns2/client.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/apns2/client.py b/apns2/client.py index 1982f49..86c4057 100644 --- a/apns2/client.py +++ b/apns2/client.py @@ -89,8 +89,9 @@ class APNsClient(object): def send_notification(self, token_hex: str, notification: Payload, topic: Optional[str] = None, priority: NotificationPriority = NotificationPriority.Immediate, expiration: Optional[int] = None, collapse_id: Optional[str] = None) -> None: - stream_id = self.send_notification_async(token_hex, notification, topic, priority, expiration, collapse_id) - result = self.get_notification_result(stream_id) + stream_id, reason = self.send_notification_async(token_hex, notification, topic, priority, expiration, collapse_id) + result = self.get_notification_result(stream_id, reason) + print(123, result) if result != 'Success': if isinstance(result, tuple): reason, info = result @@ -242,16 +243,17 @@ class APNsClient(object): connection fails, the function retries up to MAX_CONNECTION_RETRIES times. """ retries = 0 - while retries < MAX_CONNECTION_RETRIES: - # noinspection PyBroadException - try: - self._connection.connect() - logger.info('Connected to APNs') - return - except Exception: # pylint: disable=broad-except - # close the connnection, otherwise next connect() call would do nothing - self._connection.close() - retries += 1 - logger.exception('Failed connecting to APNs (attempt %s of %s)', retries, MAX_CONNECTION_RETRIES) - - raise ConnectionFailed() + return + # while retries < MAX_CONNECTION_RETRIES: + # # noinspection PyBroadException + # try: + # self._connection.connect() + # logger.info('Connected to APNs') + # return + # except Exception: # pylint: disable=broad-except + # # close the connnection, otherwise next connect() call would do nothing + # self._connection.close() + # retries += 1 + # logger.exception('Failed connecting to APNs (attempt %s of %s)', retries, MAX_CONNECTION_RETRIES) + # + # raise ConnectionFailed()