Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
polish
  • Loading branch information
Mantisus committed Jun 23, 2026
commit 53619194ac66268a7f80a292d8dc2e81a96c41a6
10 changes: 0 additions & 10 deletions src/crawlee/storage_clients/_memory/_request_queue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,23 +307,13 @@ async def reclaim_request(

@override
async def is_empty(self) -> bool:
"""Check if the queue is empty.

Returns:
True if the queue is empty, False otherwise.
"""
await self._update_metadata(update_accessed_at=True)

# Queue is empty if there are no pending requests.
return len(self._pending_requests) == 0

@override
async def is_finished(self) -> bool:
"""Check if the queue is finished.

Returns:
True if the queue is finished, False otherwise.
"""
# Queue is finished if it is empty and there are no in-progress requests.
return await self.is_empty() and len(self._in_progress_requests) == 0

Expand Down
7 changes: 4 additions & 3 deletions src/crawlee/storage_clients/_redis/_request_queue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,12 @@ async def is_empty(self) -> bool:
@retry_on_error(RedisError)
@override
async def is_finished(self) -> bool:
is_empty = await self.is_empty()

metadata = await self.get_metadata()
if not await self.is_empty():
return False

return is_empty and metadata.pending_request_count == 0
metadata = await self.get_metadata()
return metadata.pending_request_count == 0

async def _load_scripts(self) -> None:
"""Ensure Lua scripts are loaded in Redis."""
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/crawlers/_basic/test_basic_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def handler(context: BasicCrawlingContext) -> None:
await crawler.run(['https://a.placeholder.com'])

# `concurrency` tasks can be scheduled if control was never yielded with `await` during task scheduling
assert fetch_counter.call_count <= 4
assert 1 <= fetch_counter.call_count <= 4
Comment thread
vdusek marked this conversation as resolved.


async def test_respects_no_retry() -> None:
Expand Down
Loading