aboutsummaryrefslogtreecommitdiffstats
path: root/python-tornado
diff options
context:
space:
mode:
authorDevendra2013-10-06 14:39:59 +0530
committerDevendra2013-10-06 14:39:59 +0530
commit7ec3bbe414abe58072fda63f4f9c801f77b292e1 (patch)
treecec04de1825d9fab4887e40d88aa0136937fb442 /python-tornado
parent09d6ea1fa20f87dc648740ffb2a70f67e7e4efa9 (diff)
downloadpubnub-python-7ec3bbe414abe58072fda63f4f9c801f77b292e1.tar.bz2
changing timeout from 200 to 310 s, changed exception handling to not silently eat execeptions in callback
Diffstat (limited to 'python-tornado')
-rw-r--r--python-tornado/Pubnub.py15
-rw-r--r--python-tornado/examples/here-now-example.py6
-rw-r--r--python-tornado/unassembled/Platform.py13
3 files changed, 27 insertions, 7 deletions
diff --git a/python-tornado/Pubnub.py b/python-tornado/Pubnub.py
index 8f94000..a65b2b3 100644
--- a/python-tornado/Pubnub.py
+++ b/python-tornado/Pubnub.py
@@ -541,7 +541,7 @@ class PubnubCoreAsync(PubnubBase):
self.subscriptions = {}
self.timetoken = 0
- self.version = '3.4'
+ self.version = '3.3.4'
self.accept_encoding = 'gzip'
def subscribe( self, args ) :
@@ -680,6 +680,7 @@ except ImportError:
import hmac
import tornado.ioloop
+from tornado.stack_context import ExceptionStackContext
from PubnubCrypto import PubnubCrypto
ioloop = tornado.ioloop.IOLoop.instance()
@@ -718,9 +719,17 @@ class Pubnub(PubnubCoreAsync):
url = self.getUrl(request)
## Send Request Expecting JSON Response
#print self.headers
- request = tornado.httpclient.HTTPRequest( url, 'GET', self.headers, connect_timeout=310, request_timeout=310 )
+
+ request = tornado.httpclient.HTTPRequest( url, 'GET', self.headers, connect_timeout=10, request_timeout=310 )
+
def responseCallback(response):
- callback(eval(response._get_body()))
+ def handle_exc(*args):
+ return True
+ if response.error is not None:
+ with ExceptionStackContext(handle_exc):
+ response.rethrow()
+ else:
+ callback(eval(response._get_body()))
self.http.fetch(
request,
diff --git a/python-tornado/examples/here-now-example.py b/python-tornado/examples/here-now-example.py
index 4105776..85e3432 100644
--- a/python-tornado/examples/here-now-example.py
+++ b/python-tornado/examples/here-now-example.py
@@ -11,6 +11,8 @@
import sys
import tornado
+sys.path.append('..')
+sys.path.append('../../common')
from Pubnub import Pubnub
publish_key = len(sys.argv) > 1 and sys.argv[1] or 'demo'
@@ -30,7 +32,7 @@ crazy = 'hello_world'
## -----------------------------------------------------------------------
def here_now_complete(messages):
print(messages)
- tornado.ioloop.IOLoop.instance().stop()
+ pubnub.stop()
pubnub.here_now( {
'channel' : crazy,
@@ -40,4 +42,4 @@ pubnub.here_now( {
## -----------------------------------------------------------------------
## IO Event Loop
## -----------------------------------------------------------------------
-tornado.ioloop.IOLoop.instance().start()
+pubnub.start()
diff --git a/python-tornado/unassembled/Platform.py b/python-tornado/unassembled/Platform.py
index 618927e..4df04b3 100644
--- a/python-tornado/unassembled/Platform.py
+++ b/python-tornado/unassembled/Platform.py
@@ -9,6 +9,7 @@ except ImportError:
import hmac
import tornado.ioloop
+from tornado.stack_context import ExceptionStackContext
from PubnubCrypto import PubnubCrypto
ioloop = tornado.ioloop.IOLoop.instance()
@@ -47,9 +48,17 @@ class Pubnub(PubnubCoreAsync):
url = self.getUrl(request)
## Send Request Expecting JSON Response
#print self.headers
- request = tornado.httpclient.HTTPRequest( url, 'GET', self.headers, connect_timeout=310, request_timeout=310 )
+
+ request = tornado.httpclient.HTTPRequest( url, 'GET', self.headers, connect_timeout=10, request_timeout=310 )
+
def responseCallback(response):
- callback(eval(response._get_body()))
+ def handle_exc(*args):
+ return True
+ if response.error is not None:
+ with ExceptionStackContext(handle_exc):
+ response.rethrow()
+ else:
+ callback(eval(response._get_body()))
self.http.fetch(
request,