Skip to content

Handling Intermittent ValueError in _handle_eio_message with Multithreading #1269

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

You must be logged in to vote

This happens because you are receiving invalid data. The Socket.IO client is thread-safe, but you can't use the same client object concurrently on different threads. For example, if you emit on the same client instance on different threads at about the same time, the packets corresponding to these two emits may be sent in an incorrect order and mixed up.

If you are going to use the client from multiple threads, what you should do is protect the emits() with a lock.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@edvard-bjarnason
Comment options

Answer selected by TheoBoyer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants