Skip to content

Commit

Permalink
no more sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
egradman committed Sep 15, 2011
1 parent 23baa6c commit 217d5f1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python-tornado/Pubnub.py
Expand Up @@ -14,6 +14,10 @@
import hashlib
import urllib2
import tornado.httpclient
import sys

import tornado.ioloop
ioloop = tornado.ioloop.IOLoop.instance()

class Pubnub():
def __init__(
Expand Down Expand Up @@ -210,12 +214,10 @@ def sub_callback(response):
if not response:
def time_callback(_time):
if not _time:
time.sleep(1)
substabizel()
ioloop.add_timeout(time.time()+1, substabizel)
return errorback("Lost Network Connection")

time.sleep(1)
substabizel()
else:
ioloop.add_timeout(time.time()+1, substabizel)

## ENSURE CONNECTED (Call Time Function)
return self.time({ 'callback' : time_callback })
Expand All @@ -236,7 +238,8 @@ def time_callback(_time):
str(self.subscriptions[channel]['timetoken'])
], sub_callback )
except :
time.sleep(1)
ioloop.add_timeout(time.time()+1, substabizel)
return

## BEGIN SUBSCRIPTION (LISTEN FOR MESSAGES)
substabizel()
Expand Down

0 comments on commit 217d5f1

Please sign in to comment.