apify 1.1.4b2__py3-none-any.whl → 1.1.4b3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of apify might be problematic. Click here for more details.
- apify/storages/request_queue.py +9 -9
- {apify-1.1.4b2.dist-info → apify-1.1.4b3.dist-info}/METADATA +1 -1
- {apify-1.1.4b2.dist-info → apify-1.1.4b3.dist-info}/RECORD +6 -6
- {apify-1.1.4b2.dist-info → apify-1.1.4b3.dist-info}/LICENSE +0 -0
- {apify-1.1.4b2.dist-info → apify-1.1.4b3.dist-info}/WHEEL +0 -0
- {apify-1.1.4b2.dist-info → apify-1.1.4b3.dist-info}/top_level.txt +0 -0
apify/storages/request_queue.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from collections import OrderedDict
|
|
3
3
|
from datetime import datetime, timezone
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Dict, Optional
|
|
5
5
|
from typing import OrderedDict as OrderedDictType
|
|
6
6
|
from typing import Set, Union
|
|
7
7
|
|
|
@@ -75,7 +75,7 @@ class RequestQueue(BaseStorage):
|
|
|
75
75
|
_request_queue_client: Union[RequestQueueClientAsync, RequestQueueClient]
|
|
76
76
|
_client_key = _crypto_random_object_id()
|
|
77
77
|
_queue_head_dict: OrderedDictType[str, str]
|
|
78
|
-
|
|
78
|
+
_query_queue_head_task: Optional[asyncio.Task]
|
|
79
79
|
_in_progress: Set[str]
|
|
80
80
|
_last_activity: datetime
|
|
81
81
|
_internal_timeout_seconds = 5 * 60
|
|
@@ -100,7 +100,7 @@ class RequestQueue(BaseStorage):
|
|
|
100
100
|
|
|
101
101
|
self._request_queue_client = client.request_queue(self._id, client_key=self._client_key)
|
|
102
102
|
self._queue_head_dict = OrderedDict()
|
|
103
|
-
self.
|
|
103
|
+
self._query_queue_head_task = None
|
|
104
104
|
self._in_progress = set()
|
|
105
105
|
self._last_activity = datetime.now(timezone.utc)
|
|
106
106
|
self._recently_handled = LRUCache[bool](max_length=RECENTLY_HANDLED_CACHE_SIZE)
|
|
@@ -369,7 +369,7 @@ class RequestQueue(BaseStorage):
|
|
|
369
369
|
|
|
370
370
|
def _reset(self) -> None:
|
|
371
371
|
self._queue_head_dict.clear()
|
|
372
|
-
self.
|
|
372
|
+
self._query_queue_head_task = None
|
|
373
373
|
self._in_progress.clear()
|
|
374
374
|
self._recently_handled.clear()
|
|
375
375
|
self._assumed_total_count = 0
|
|
@@ -402,7 +402,7 @@ class RequestQueue(BaseStorage):
|
|
|
402
402
|
})
|
|
403
403
|
|
|
404
404
|
# This is needed so that the next call to _ensureHeadIsNonEmpty() will fetch the queue head again.
|
|
405
|
-
self.
|
|
405
|
+
self._query_queue_head_task = None
|
|
406
406
|
|
|
407
407
|
return {
|
|
408
408
|
'wasLimitReached': len(list_head['items']) >= limit,
|
|
@@ -420,15 +420,15 @@ class RequestQueue(BaseStorage):
|
|
|
420
420
|
if limit is None:
|
|
421
421
|
limit = max(self._in_progress_count() * QUERY_HEAD_BUFFER, QUERY_HEAD_MIN_LENGTH)
|
|
422
422
|
|
|
423
|
-
if self.
|
|
424
|
-
self.
|
|
423
|
+
if self._query_queue_head_task is None:
|
|
424
|
+
self._query_queue_head_task = asyncio.Task(self._queue_query_head(limit))
|
|
425
425
|
|
|
426
|
-
queue_head = await self.
|
|
426
|
+
queue_head = await self._query_queue_head_task
|
|
427
427
|
|
|
428
428
|
# TODO: I feel this code below can be greatly simplified... (comes from TS implementation *wink*)
|
|
429
429
|
|
|
430
430
|
""" If queue is still empty then one of the following holds:
|
|
431
|
-
- the other calls waiting for this
|
|
431
|
+
- the other calls waiting for this task already consumed all the returned requests
|
|
432
432
|
- the limit was too low and contained only requests in progress
|
|
433
433
|
- the writes from other clients were not propagated yet
|
|
434
434
|
- the whole queue was processed and we are done
|
|
@@ -24,10 +24,10 @@ apify/storages/__init__.py,sha256=oYUCrNcECYMXX0wtHbaYhD2hWH3drau8OyXVdtNOk80,24
|
|
|
24
24
|
apify/storages/base_storage.py,sha256=l0OB1w23rwDK_cnvp33W725T4aHUXexlOHRUCNCs4RU,7089
|
|
25
25
|
apify/storages/dataset.py,sha256=kyhlddpE_a3QetoT-LgY1Q2F_YWHE2ZSP1HXjP68QC0,23436
|
|
26
26
|
apify/storages/key_value_store.py,sha256=3lF3dNb3uvWKSmza5Qb9-Dna4czCOcPOImzwDVzgdjc,10132
|
|
27
|
-
apify/storages/request_queue.py,sha256=
|
|
27
|
+
apify/storages/request_queue.py,sha256=KCvSYzJ-9pgGvfTnX-K05Mdb3wq7UROtxW8zczrE6ZI,25891
|
|
28
28
|
apify/storages/storage_client_manager.py,sha256=zqrjVpSE4eM6BM3Z87yLmNxMsiZep8bf0aSaX8125PE,2224
|
|
29
|
-
apify-1.1.
|
|
30
|
-
apify-1.1.
|
|
31
|
-
apify-1.1.
|
|
32
|
-
apify-1.1.
|
|
33
|
-
apify-1.1.
|
|
29
|
+
apify-1.1.4b3.dist-info/LICENSE,sha256=_yIHo4TZezG4fMaWG1Er6OH7DW7MiZI-KO4dnONASZI,11355
|
|
30
|
+
apify-1.1.4b3.dist-info/METADATA,sha256=hwZOal8_4B4xdGLpKVQZkowaWFvgws-OC9VKM6hbjQM,6285
|
|
31
|
+
apify-1.1.4b3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
32
|
+
apify-1.1.4b3.dist-info/top_level.txt,sha256=2oFNsHggn5m_rCaaP7xijQg_-Va2ByOSYuvKgACsS5w,6
|
|
33
|
+
apify-1.1.4b3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|