From 03a0915461bc0f1d586abc5826ea41797b1cec2d Mon Sep 17 00:00:00 2001 From: Max Bohomolov Date: Mon, 16 Dec 2024 22:38:02 +0000 Subject: [PATCH] fix event migrating handler --- src/crawlee/storages/_request_queue.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crawlee/storages/_request_queue.py b/src/crawlee/storages/_request_queue.py index 4f0d746c50..f93cf7f4bd 100644 --- a/src/crawlee/storages/_request_queue.py +++ b/src/crawlee/storages/_request_queue.py @@ -119,8 +119,8 @@ def __init__(self, id: str, name: str | None, storage_client: BaseStorageClient) self._queue_paused_for_migration = False event_manager.on(event=Event.MIGRATING, listener=lambda _: setattr(self, '_queue_paused_for_migration', True)) - event_manager.on(event=Event.MIGRATING, listener=lambda _: self._clear_possible_locks()) - event_manager.on(event=Event.ABORTING, listener=lambda _: self._clear_possible_locks()) + event_manager.on(event=Event.MIGRATING, listener=self._clear_possible_locks) + event_manager.on(event=Event.ABORTING, listener=self._clear_possible_locks) # Other internal attributes self._tasks = list[asyncio.Task]() @@ -494,7 +494,7 @@ async def is_finished(self) -> bool: 'Queue head still returned requests that need to be processed (or that are locked by other clients)', ) - return not current_head.items and not self._in_progress + return (not current_head.items and not self._in_progress) or self._queue_paused_for_migration async def get_info(self) -> RequestQueueMetadata | None: """Get an object containing general information about the request queue."""