Closed maartenbreddels closed 6 months ago
Hi,
I'm using flask_sock (cc @miguelgrinberg) which uses simple-websocket, which uses this project, and we found some flakeyness in our CI for Solara.
About 1 in 5 runs on CI and 1 in 50 runs on our local machines gave corrupt websocket messages, which triggered errors in json parsing.
I believe the reason is because FrameProtocol is not thread safe due to _outbound_opcode. See
FrameProtocol
_outbound_opcode
I'm not sure if this should be documented or if this can be fixed. The workaround for us now is to put a mutex around the send and close calls:
Do you think this is sufficient? We only call receive from the same thread, but send will only also be called from other threads.
I would love to get your opinions on this.
Regards,
Maarten
Yes, a mutex is one possible option. Happy to review and merge a PR to mention it in the docs.
Hi,
I'm using flask_sock (cc @miguelgrinberg) which uses simple-websocket, which uses this project, and we found some flakeyness in our CI for Solara.
About 1 in 5 runs on CI and 1 in 50 runs on our local machines gave corrupt websocket messages, which triggered errors in json parsing.
I believe the reason is because
FrameProtocol
is not thread safe due to_outbound_opcode
. SeeI'm not sure if this should be documented or if this can be fixed. The workaround for us now is to put a mutex around the send and close calls:
Do you think this is sufficient? We only call receive from the same thread, but send will only also be called from other threads.
I would love to get your opinions on this.
Regards,
Maarten