Skip to content

Commit

Permalink
Deliver callbacks from different namespaces (Fixes #1909)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Nov 20, 2022
1 parent 94692d3 commit 94240a4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/flask_socketio/__init__.py
Expand Up @@ -443,13 +443,15 @@ def ping():
if callback:
# wrap the callback so that it sets app app and request contexts
sid = None
original_callback = callback
original_namespace = namespace
if has_request_context():
sid = getattr(flask.request, 'sid', None)
original_callback = callback
original_namespace = getattr(flask.request, 'namespace', None)

def _callback_wrapper(*args):
return self._handle_event(original_callback, None, namespace,
sid, *args)
return self._handle_event(original_callback, None,
original_namespace, sid, *args)

if sid:
# the callback wrapper above will install a request context
Expand Down

0 comments on commit 94240a4

Please sign in to comment.