feat: Implement the is_finished method in the ApifyStorageClient#1008
Open
Mantisus wants to merge 2 commits into
Open
feat: Implement the is_finished method in the ApifyStorageClient#1008Mantisus wants to merge 2 commits into
is_finished method in the ApifyStorageClient#1008Mantisus wants to merge 2 commits into
Conversation
vdusek
requested changes
Jun 23, 2026
vdusek
reviewed
Jun 25, 2026
| async def is_finished(self) -> bool: | ||
| """Specific implementation of this method for the RQ shared access mode.""" | ||
| async with self._fetch_lock: | ||
| return await self._is_empty() and not self._queue_has_locked_requests |
Contributor
There was a problem hiding this comment.
This relies on await self._is_empty() is being evaluated first (it calls _list_head, which populates self._queue_has_locked_requests). A reorder would break the finished detection. Maybe we could add a comment noting the ordering dependency.
| @@ -279,7 +279,11 @@ async def is_empty(self) -> bool: | |||
| """Specific implementation of this method for the RQ single access mode.""" | |||
| # Without the lock the `is_empty` is prone to falsely report True with some low probability race condition. | |||
Contributor
There was a problem hiding this comment.
This comment is now outdated and misleading. Could you update it?
| assert metadata.pending_request_count == 0, f'metadata.pending_request_count={metadata.pending_request_count}' | ||
|
|
||
|
|
||
| async def test_is_empty_and_is_finished(request_queue_apify: RequestQueue, rq_poll_timeout: int) -> None: |
Contributor
There was a problem hiding this comment.
For the most part, this duplicates the existing test_request_queue_is_finished test. Could we consolidate them into one? And parametrized it single+shared.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Implement the
is_finishedmethod in theApifyStorageClientCloses: #987
Follow-up: apify/crawlee-python#1982