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

Changed the default converters to use local instead of class variables #1110

Merged
merged 1 commit into from May 3, 2023

Conversation

mircopz
Copy link
Contributor

@mircopz mircopz commented May 2, 2023

Fix as indicated in #1103

The value returned by a converter must not be a reference to a static variable. Instead, in this project the default converters use a class variable (self.dict_result) to process the received message, and return it at the end.

So if 2 different messages are queued in __converted_data_queue while __send_to_storage thread is in its 0.2s sleep, when it wakes up it found a queue of size 2 but both elements have the same reference, whose value is both times the last value assigned to that variable (the last converted message).

The solution is to use a local variable inside the convert function (dict_result instead of self.dict_result).

@imbeacon imbeacon merged commit ded7ae7 into thingsboard:master May 3, 2023
1 check passed
@mircopz mircopz deleted the feature/fix-convert-return branch May 3, 2023 07:11
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

Successfully merging this pull request may close these issues.

None yet

2 participants