fix: avoid concurrent data collectors #296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Acceptance Criteria
We should make sure we won't run the DataCollector daemon's logic concurrently in the asyncio event loop.
Each execution should wait for the previous one to finish before starting.
The way we did it before left the possibility of having several async tasks in the event loop at once, in case they took more than 1 second to finish.
For instance, supposing each of them took 5 seconds to finish, we would have 5 tasks running concurrently.
By looking at the number of concurrent executions in the Lambda that is called by this daemon, we can see that sometimes we had even 9 concurrent executions:
I suspect this could be related to high memory consumption in the daemon, but I'm not 100% sure. The fix looked beneficial anyway.
Security Checklist