losing registered handlers in a socketio instance when calling init_app #2145
rienafairefr
started this conversation in
General
Replies: 1 comment
-
This has been asked and discussed many times. Flask-SocketIO is a Flask extension. You have two options to configure it: Option 1: Pass your configuration when you call the There is no supported option in which you pass some arguments in the constructor and some others in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was prototyping something out of flask-socketio a client-server setup with an remote external process and I was surprised by something in the initialisation, managed to build a minimally reproducible code below.
server code
An even more mimimal example, without
socketio.run()
:which gives this log when runs:
In the first case, well, the handler is registered, init_app is called once in the __init__ of socketio.SocketIO
but then self.server is initialized in again init_app (in my actual app code the init_app was called in a create_app factory, as I usually do for flask-* apps ), and the handlers are lost in the ether.
In the second case, the handlers are registered on the
handlers
attribute of the socketio instance instead of self.server.handlers, so they are re-added to the socketio.server in init_appI think it might be called a bug in flask-socketio, but I'm not sure (this is more of a edge case when both using message_queue and an app factory. All the code paths I looked at are 5 to 10 years old so this might be more a case of "I didn't read the docs enough"
related discussions (I think) : the symptom is similar (handler seemingly defined but not called)
#2136
#2136
Beta Was this translation helpful? Give feedback.
All reactions