Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not thread safe #186

Closed
maartenbreddels opened this issue Sep 29, 2023 · 1 comment
Closed

Not thread safe #186

maartenbreddels opened this issue Sep 29, 2023 · 1 comment

Comments

@maartenbreddels
Copy link

maartenbreddels commented Sep 29, 2023

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

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

@Kriechi
Copy link
Member

Kriechi commented Feb 24, 2024

Yes, a mutex is one possible option.
Happy to review and merge a PR to mention it in the docs.

@Kriechi Kriechi closed this as completed Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants