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

Access to original_message is not thread-safe #7

Closed
Alerion opened this issue Mar 14, 2017 · 2 comments
Closed

Access to original_message is not thread-safe #7

Alerion opened this issue Mar 14, 2017 · 2 comments
Assignees
Labels

Comments

@Alerion
Copy link
Contributor

Alerion commented Mar 14, 2017

This code is not thread-safe:

global original_message
original_message = original_msg
result = method(*args, **kwargs)
original_message = None

If you have two JsonRpcWebsocketConsumer you can get a moment, when one thread reset original_message and other tries to read it.

@millerf millerf self-assigned this Mar 14, 2017
@millerf millerf added the bug label Mar 14, 2017
@Alerion
Copy link
Contributor Author

Alerion commented Mar 14, 2017

Possible solution to pass original messages if method expects this argument:

func_args, _, _, _ = getargspec(method)
if 'original_msg' in func_args:
    kwargs['original_msg'] = original_message
result = method(*args, **kwargs)

@millerf
Copy link
Owner

millerf commented Mar 16, 2017

I am not a great fan of forcing the value of a parameter based on its name... I will try to find a better way...
At the moment I am also trying to create a test that shows the problem. And I am having a hard time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants