Skip to content

socketio.run() locking code execution #2072

Answered by miguelgrinberg
Apapora asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can run the server in a background thread. Something like this:

if __name__ == "__main__":
    socketio.start_background_task(socketio.run, app, port=5555, debug=True)
    print("this will print")

But now you have a problem, because this will cause the application to end. Whatever you do after starting the server must keep the script from exiting.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Apapora
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants