[fix] Background task update_config launched multiple times #1128#1141
[fix] Background task update_config launched multiple times #1128#1141nemesifier merged 6 commits intomasterfrom
Conversation
nemesifier
left a comment
There was a problem hiding this comment.
What do you think of something like the following?
Before sending the config_modified signal for a device we check for a cache key that is unique per device, if the cache key is set, we don't send the signal otherwise we proceed.
After sending the config_modified signal for a device we can set the cache key (unique for each device) with a short duration, eg: 5 seconds (we need some heuristics to find out the right amount of seconds but it cannot be too long otherwise different changes unrelated to one another may not fire config updates).
I outlined the ideal behavior in #1142. For now, let's focus on mitigating this issue.
There was a problem hiding this comment.
Why check if it's None? Wouldn't just check if it's truthy be enough?
There was a problem hiding this comment.
Yes, you are correct. I just wanted to be 100% sure that the cache does not contain the key.
35ca61a to
098cde7
Compare
0c78668 to
33a222a
Compare
There was a problem hiding this comment.
This reminds me of the django-allauth rate limiting which we had to disable in tests.
The problem with this approach of modifying each test is that all contributors have to be aware of this, which is not scalable for future maintenance.
We need to look for a solution that doesn't require contributors to be aware of this all the time.
What if we make the timeout configurable with a setting? That would allow us to disable it globally during tests and enable it only in the subset of tests where it is needed.
There was a problem hiding this comment.
| prevents emitting duplicate signals inside the same logical window; | |
| prevents emitting duplicate signals inside the same change window; |
There was a problem hiding this comment.
| if that key exists the method returns early without emitting. | |
| if that key exists the method returns without emitting the signal again. |
135531d to
f4e3b99
Compare
Checklist
Reference to Existing Issue
Fixes #1128
TODOS