Skip to content

Commit

Permalink
compatibility with Python 2.7's changes to xmlrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnyhero authored and bunnyhero committed Dec 23, 2010
1 parent e6230c2 commit a2ebf83
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyapns/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import xmlrpclib
import threading
import httplib
from sys import hexversion

OPTIONS = {'CONFIGURED': False, 'TIMEOUT': 20}

Expand Down Expand Up @@ -93,8 +94,12 @@ def ServerProxy(url, *args, **kwargs):

class TimeoutTransport(xmlrpclib.Transport):
def make_connection(self, host):
conn = TimeoutHTTP(host)
conn.set_timeout(self.timeout)
if hexversion < 0x02070000:
conn = TimeoutHTTP(host)
conn.set_timeout(self.timeout)
else:
conn = TimeoutHTTPConnection(host)
conn.timeout = self.timeout
return conn

class TimeoutHTTPConnection(httplib.HTTPConnection):
Expand Down

0 comments on commit a2ebf83

Please sign in to comment.