aboutsummaryrefslogtreecommitdiffstats
path: root/Pubnub.py
diff options
context:
space:
mode:
authorJay Oster2014-07-18 20:49:49 -0700
committerJay Oster2014-07-18 20:49:49 -0700
commit3dfd0de909066cbbd8407b7889eeadb788197989 (patch)
treeb0b3a825c2218783792ca1016af867efc4ebaa02 /Pubnub.py
parent359b831b3eed191159e79e943d77077bc112a7cf (diff)
downloadpubnub-python-3dfd0de909066cbbd8407b7889eeadb788197989.tar.bz2
DataSync: Fix double-GET in get_synched_object
- Use single multiplex subscribe for all channels - Key the initial object GET on a single channel's connect callback - Don't store empty messages into the action list (comes from the GET completion callback)
Diffstat (limited to 'Pubnub.py')
-rw-r--r--Pubnub.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Pubnub.py b/Pubnub.py
index 9286c9a..3c97643 100644
--- a/Pubnub.py
+++ b/Pubnub.py
@@ -714,11 +714,14 @@ class PubnubBase(object):
self.error_callback = _error
def _connect(message):
- timestamp = self.timetoken
- _read(object_id, timestamp, path=path_slashes)
+ if message == self.ds_location:
+ timestamp = self.timetoken
+ _read(object_id, timestamp, path=path_slashes)
def _callback(message, channel):
- self.ds_action_list.append(message)
+ if message:
+ self.ds_action_list.append(message)
+
if self.timetoken > self.ds_timetoken:
self.ds_timetoken = self.timetoken
if channel.startswith('pn_ds_'):
@@ -749,10 +752,9 @@ class PubnubBase(object):
def _read_callback(message):
self.ds_action_list.append(message)
- if 'messaage' in message and message['message'] != 'OK':
+ if 'message' not in message or message['message'] != 'OK':
_error(message['message'])
-
- if 'next_page' in message and message['next_page'] is not None:
+ elif 'next_page' in message and message['next_page'] is not None:
self.ds_temp.append(message['payload'])
_read(object_id, obj_at, path=message['start_at'])
else:
@@ -770,15 +772,11 @@ class PubnubBase(object):
self._request({'urlcomponents': url_components, 'urlparams': url_params}, callback=_read_callback)
self.ds_location = 'pn_ds_' + object_id + path
- self.subscribe(channels=['pn_ds_' + object_id + path, 'pn_ds_' + object_id + path + '.*'],
+ self.subscribe(channels=['pn_ds_' + object_id + path, 'pn_ds_' + object_id + path + '.*', 'pn_dstr_' + object_id],
connect=_connect,
callback=_callback,
error=_error)
- self.subscribe(channels='pn_dstr_' + object_id,
- callback=_callback,
- error=_error)
-
def _format_path(self, path):
if not path.startswith('.'):
path = '.' + path
@@ -1867,4 +1865,4 @@ class PubnubTornado(PubnubCoreAsync):
def abort():
pass
- return abort \ No newline at end of file
+ return abort