You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sources/platform/storage/request_queue.md
+62-22Lines changed: 62 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -407,7 +407,10 @@ You can lock a request so that no other clients receive it when they fetch the q
407
407
This feature is seamlessly integrated into Crawlee, requiring minimal extra setup. By default, requests are locked for the same duration as the timeout for processing requests in the crawler ([`requestHandlerTimeoutSecs`](https://crawlee.dev/api/next/basic-crawler/interface/BasicCrawlerOptions#requestHandlerTimeoutSecs)).
408
408
If the Actor processing the request fails, the lock expires, and the request is processed again eventually. For more details, refer to the [Crawlee documentation](https://crawlee.dev/docs/next/experiments/experiments-request-locking).
409
409
410
-
In the following example, we demonstrate how we can use locking mechanisms to avoid concurrent processing of the same request.
410
+
In the following example, we demonstrate how we can use locking mechanisms to avoid concurrent processing of the same request across multiple Actor runs.
console.log(`Was the request locked by the first client locked by the second client? ${wasTheClientTwoLockedSameRequest}`);
477
525
console.log(`Request locked until ${requestLockedByClientOne?.lockExpiresAt}`);
478
526
479
527
// Other clients cannot modify the lock; attempting to do so will throw an error.
@@ -486,21 +534,13 @@ try {
486
534
// This will throw an error.
487
535
}
488
536
489
-
// Prolongs the lock of the first request or unlocks it.
490
-
await requestQueueClientOne.prolongRequestLock(
491
-
theFirstRequestLockedByClientOne.id,
492
-
{ lockSecs: 60 },
493
-
);
494
-
await requestQueueClientOne.deleteRequestLock(
495
-
theFirstRequestLockedByClientOne.id,
496
-
);
497
-
498
-
// Cleans up the queue.
499
-
await requestQueueClientOne.delete();
500
537
501
538
await Actor.exit();
502
539
```
503
540
541
+
</TabItem>
542
+
</Tabs>
543
+
504
544
A detailed tutorial on how to process one request queue with multiple Actor runs can be found in [Academy tutorials](https://docs.apify.com/academy/node-js/multiple-runs-scrape).
0 commit comments