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

Fix issue with querying request queue head multiple times in parallel #113

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

fnesveda
Copy link
Member

When calling _ensure_head_is_non_empty on RequestQueue, the call to query the RQ head is cached (as an optimization) so that multiple parallel calls to the storage are not made, and in each call of _ensure_head_is_non_empty the cached call is then awaited.

In Python (unlike JavaScript), you can't await the result of an async function multiple times, it leads to an error. To get around that, you can wrap the result of the coroutine into an asyncio.Task, and that you can await multiple times (asyncio.Task behaves sort of like a JS Promise in this regard).

@fnesveda fnesveda added t-platform Issues with this label are in the ownership of the platform team. adhoc Ad-hoc unplanned task added during the sprint. labels Aug 31, 2023
@fnesveda fnesveda added this to the 71st sprint - Platform team milestone Aug 31, 2023
@fnesveda fnesveda self-assigned this Aug 31, 2023
Copy link
Contributor

@vdusek vdusek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fnesveda fnesveda merged commit 7dffcff into master Sep 1, 2023
18 checks passed
@fnesveda fnesveda deleted the fix/rq-multiple-awaits branch September 1, 2023 06:03
@fnesveda fnesveda added the validated Issues that are resolved and their solutions fulfill the acceptance criteria. label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adhoc Ad-hoc unplanned task added during the sprint. t-platform Issues with this label are in the ownership of the platform team. validated Issues that are resolved and their solutions fulfill the acceptance criteria.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants