Triggering a client callback before the end of the event handler #1494
-
The docs say that to trigger a client callback in a server's event handler, you return the list of values to pass to the client. But what if I want to do some other things in the event handler after triggering the callback? @sio.event
def my_event(sid, data):
value_to_return = do_something_with_data(data)
### returning the value as in
# return value_to_return
### would end the function here
trigger_callback(value_to_return)
do_more_things_with_data(data) |
Beta Was this translation helpful? Give feedback.
Answered by
miguelgrinberg
Sep 15, 2025
Replies: 1 comment 2 replies
-
The callback is a special signal that tells the other side that the event handler it requested ran to completion, it cannot be used for other purposes. If you want to send something to the other side while the event handler is running, you can use |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do this:
Then you write the data processing part in a separate
process_data
function.