1
1
from __future__ import annotations
2
2
3
- import asyncio
4
3
from collections import deque
5
4
from datetime import datetime , timedelta , timezone
6
5
from logging import getLogger
@@ -40,7 +39,6 @@ def __init__(
40
39
self ,
41
40
* ,
42
41
api_client : RequestQueueClientAsync ,
43
- lock : asyncio .Lock ,
44
42
) -> None :
45
43
"""Initialize a new instance.
46
44
@@ -49,14 +47,11 @@ def __init__(
49
47
self ._api_client = api_client
50
48
"""The Apify request queue client for API operations."""
51
49
52
- self ._lock = lock
53
- """A lock to ensure that only one operation is performed at a time."""
54
-
55
50
self ._queue_head = deque [str ]()
56
51
"""A deque to store request IDs in the queue head."""
57
52
58
53
self ._requests_cache : LRUCache [str , CachedRequest ] = LRUCache (maxsize = self ._MAX_CACHED_REQUESTS )
59
- """A cache to store request objects."""
54
+ """A cache to store request objects. Request ID is used as the cache key. """
60
55
61
56
self ._queue_has_locked_requests : bool | None = None
62
57
"""Whether the queue has requests locked by another client."""
@@ -162,7 +157,6 @@ async def open(
162
157
163
158
return cls (
164
159
api_client = apify_rq_client ,
165
- lock = asyncio .Lock (),
166
160
)
167
161
168
162
@override
@@ -174,8 +168,7 @@ async def purge(self) -> None:
174
168
175
169
@override
176
170
async def drop (self ) -> None :
177
- async with self ._lock :
178
- await self ._api_client .delete ()
171
+ await self ._api_client .delete ()
179
172
180
173
@override
181
174
async def add_batch_of_requests (
@@ -632,7 +625,7 @@ def _cache_request(
632
625
"""Cache a request for future use.
633
626
634
627
Args:
635
- cache_key: The key to use for caching the request.
628
+ cache_key: The key to use for caching the request. It should be request ID.
636
629
processed_request: The processed request information.
637
630
forefront: Whether the request was added to the forefront of the queue.
638
631
hydrated_request: The hydrated request object, if available.
0 commit comments