Skip to content

Commit

Permalink
Fix python server callback ID conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Jun 19, 2023
1 parent 17996b7 commit 8e7b096
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/perspective/perspective/manager/manager_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _process_subscribe(self, msg, table_or_view, post_callback, client_id):
elif callback_id is not None:
# pop the callback from the cache of the manager, and
# remove each of them from the underlying table or view
popped_callbacks = self._callback_cache.pop_callbacks(callback_id)
popped_callbacks = self._callback_cache.pop_callbacks(client_id, callback_id)

for callback in popped_callbacks:
getattr(table_or_view, method)(callback["callback"])
Expand Down
5 changes: 3 additions & 2 deletions python/perspective/perspective/table/_callback_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def remove_callbacks(self, condition):
raise ValueError("callback filter condition must be a callable function!")
self._callbacks = [callback for callback in self._callbacks if condition(callback) is False]

def pop_callbacks(self, callback_id):
def pop_callbacks(self, client_id, callback_id):
"""Removes and returns a list of callbacks with the given
`callback_id`.
Expand All @@ -40,11 +40,12 @@ def pop_callbacks(self, callback_id):
new_callbacks = []

for callback in self._callbacks:
if callback["callback_id"] == callback_id:
if callback["callback_id"] == callback_id and callback["client_id"] == client_id:
popped.append(callback)
else:
new_callbacks.append(callback)

self._callbacks = new_callbacks
return popped

def get_callbacks(self):
Expand Down

0 comments on commit 8e7b096

Please sign in to comment.