Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import select
import time
import collections, itertools
from collections import OrderedDict
import logging
import threading
try:
Expand Down Expand Up @@ -225,11 +226,11 @@ def _connect(self):
break
except SSLError as ex:
if ex.args[0] == SSL_ERROR_WANT_READ:
sys.exc_clear()
continue
elif ex.args[0] == SSL_ERROR_WANT_WRITE:
sys.exc_clear()
continue
else:
raise
raise

self.connection_alive = True
_logger.debug("%s APNS connection established" % self.__class__.__name__)
Expand Down Expand Up @@ -320,18 +321,18 @@ def __init__(self, alert=None, badge=None, sound=None, category=None, custom=Non

def dict(self):
"""Returns the payload as a regular Python dictionary"""
d = {}
d = OrderedDict()
if self.sound:
d['sound'] = self.sound
if self.badge is not None:
d['badge'] = int(self.badge)
if self.alert:
# Alert can be either a string or a PayloadAlert
# object
if isinstance(self.alert, PayloadAlert):
d['alert'] = self.alert.dict()
else:
d['alert'] = self.alert
if self.sound:
d['sound'] = self.sound
if self.badge is not None:
d['badge'] = int(self.badge)
if self.category:
d['category'] = self.category

Expand Down