Is it possible to emit a message from a function? #2034
-
I have an app.py and a get_data.py. The latter has a for loop that I would like to emit the progress of using socket.io emit. I am passing the socketio object from app.py to the function, and I can see in the verbose logging that there is a emit call going out. However, I am unable to see the results of that call both in the webpage and the app.py. The app.py and webpage can communicate with each other successfully, I am having trouble with them receiving messages from get_data.py. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This has to be a bug in your own application. The example app.py in this repository emits from a separate function that even runs on a separate thread. Usually what helps is to simplify the application until you can provide it to me for debugging. In 9 out of 10 cases you will figure out what's wrong yourself without getting to a point that you can share your code. |
Beta Was this translation helpful? Give feedback.
You are running the for loop before returning the template to the browser, which in turn will allow the browser to make a connection. You may want to loop at the example I referenced earlier, which uses a background thread for the function.