File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/apify/storage_clients/_apify Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 66from typing_extensions import override
77
88from apify_client .clients import RequestQueueClientAsync
9+ from crawlee ._utils .crypto import crypto_random_object_id
910from crawlee .storage_clients ._base import RequestQueueClient
1011from crawlee .storages import RequestQueue
1112
@@ -263,4 +264,10 @@ def _get_metadata(raw_metadata: dict | None) -> ApifyRequestQueueMetadata:
263264 return ApifyRequestQueueMetadata .model_validate (raw_metadata )
264265
265266 def _get_resource_client (self , id : str ) -> RequestQueueClientAsync :
266- return self ._api_client .request_queue (request_queue_id = id )
267+ # Use suitable client_key to make `hadMultipleClients` response of Apify API useful.
268+ # It should persist across migrated or resurrected Actor runs on the Apify platform.
269+ _api_max_client_key_length = 32
270+ client_key = (self ._configuration .actor_run_id or crypto_random_object_id (length = _api_max_client_key_length ))[
271+ :_api_max_client_key_length
272+ ]
273+ return self ._api_client .request_queue (request_queue_id = id , client_key = client_key )
You can’t perform that action at this time.
0 commit comments