crawlee 0.6.13b15__py3-none-any.whl → 1.3.1b3__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 crawlee might be problematic. Click here for more details.
- crawlee/__init__.py +2 -1
- crawlee/_autoscaling/snapshotter.py +1 -1
- crawlee/_browserforge_workaround.py +7 -3
- crawlee/_request.py +64 -43
- crawlee/_service_locator.py +44 -24
- crawlee/_types.py +128 -36
- crawlee/_utils/context.py +3 -3
- crawlee/_utils/file.py +8 -1
- crawlee/_utils/globs.py +4 -4
- crawlee/_utils/raise_if_too_many_kwargs.py +12 -0
- crawlee/_utils/recoverable_state.py +32 -8
- crawlee/_utils/recurring_task.py +27 -3
- crawlee/_utils/requests.py +0 -26
- crawlee/_utils/robots.py +17 -5
- crawlee/_utils/sitemap.py +16 -7
- crawlee/_utils/system.py +30 -14
- crawlee/_utils/time.py +120 -0
- crawlee/_utils/urls.py +9 -2
- crawlee/browsers/_browser_pool.py +5 -2
- crawlee/browsers/_playwright_browser.py +2 -1
- crawlee/browsers/_playwright_browser_controller.py +21 -15
- crawlee/browsers/_playwright_browser_plugin.py +17 -3
- crawlee/browsers/_types.py +1 -1
- crawlee/configuration.py +2 -0
- crawlee/crawlers/__init__.py +5 -1
- crawlee/crawlers/_abstract_http/__init__.py +2 -1
- crawlee/crawlers/_abstract_http/_abstract_http_crawler.py +57 -17
- crawlee/crawlers/_abstract_http/_abstract_http_parser.py +1 -1
- crawlee/crawlers/_abstract_http/_http_crawling_context.py +1 -1
- crawlee/crawlers/_adaptive_playwright/__init__.py +5 -2
- crawlee/crawlers/_adaptive_playwright/_adaptive_playwright_crawler.py +27 -32
- crawlee/crawlers/_adaptive_playwright/_adaptive_playwright_crawler_statistics.py +1 -1
- crawlee/crawlers/_adaptive_playwright/_adaptive_playwright_crawling_context.py +8 -3
- crawlee/crawlers/_adaptive_playwright/_rendering_type_predictor.py +1 -1
- crawlee/crawlers/_basic/_basic_crawler.py +254 -148
- crawlee/crawlers/_basic/_context_utils.py +24 -0
- crawlee/crawlers/_basic/_logging_utils.py +27 -4
- crawlee/crawlers/_beautifulsoup/_beautifulsoup_crawler.py +2 -2
- crawlee/crawlers/_parsel/_parsel_crawler.py +2 -2
- crawlee/crawlers/_parsel/_parsel_parser.py +1 -1
- crawlee/crawlers/_playwright/_playwright_crawler.py +73 -23
- crawlee/crawlers/_playwright/_playwright_http_client.py +7 -1
- crawlee/crawlers/_playwright/_playwright_pre_nav_crawling_context.py +4 -1
- crawlee/crawlers/_playwright/_types.py +12 -2
- crawlee/errors.py +4 -0
- crawlee/events/_event_manager.py +12 -6
- crawlee/events/_types.py +6 -6
- crawlee/fingerprint_suite/_browserforge_adapter.py +1 -1
- crawlee/fingerprint_suite/_fingerprint_generator.py +3 -0
- crawlee/fingerprint_suite/_header_generator.py +2 -2
- crawlee/fingerprint_suite/_types.py +2 -2
- crawlee/http_clients/_base.py +4 -0
- crawlee/http_clients/_curl_impersonate.py +68 -14
- crawlee/http_clients/_httpx.py +16 -6
- crawlee/http_clients/_impit.py +32 -11
- crawlee/otel/crawler_instrumentor.py +4 -6
- crawlee/project_template/{{cookiecutter.project_name}}/pyproject.toml +2 -2
- crawlee/project_template/{{cookiecutter.project_name}}/requirements.txt +3 -0
- crawlee/request_loaders/_request_list.py +3 -3
- crawlee/request_loaders/_request_loader.py +5 -1
- crawlee/request_loaders/_sitemap_request_loader.py +248 -50
- crawlee/router.py +13 -3
- crawlee/sessions/_cookies.py +13 -8
- crawlee/sessions/_models.py +5 -5
- crawlee/sessions/_session_pool.py +1 -1
- crawlee/statistics/_error_snapshotter.py +1 -1
- crawlee/statistics/_models.py +62 -12
- crawlee/statistics/_statistics.py +24 -33
- crawlee/storage_clients/__init__.py +16 -0
- crawlee/storage_clients/_base/_dataset_client.py +2 -2
- crawlee/storage_clients/_base/_key_value_store_client.py +2 -2
- crawlee/storage_clients/_base/_request_queue_client.py +2 -2
- crawlee/storage_clients/_base/_storage_client.py +13 -0
- crawlee/storage_clients/_file_system/_dataset_client.py +33 -30
- crawlee/storage_clients/_file_system/_key_value_store_client.py +34 -27
- crawlee/storage_clients/_file_system/_request_queue_client.py +171 -154
- crawlee/storage_clients/_file_system/_storage_client.py +16 -3
- crawlee/storage_clients/_file_system/_utils.py +0 -0
- crawlee/storage_clients/_memory/_dataset_client.py +16 -4
- crawlee/storage_clients/_memory/_key_value_store_client.py +16 -4
- crawlee/storage_clients/_memory/_request_queue_client.py +55 -36
- crawlee/storage_clients/_memory/_storage_client.py +6 -3
- crawlee/storage_clients/_redis/__init__.py +6 -0
- crawlee/storage_clients/_redis/_client_mixin.py +292 -0
- crawlee/storage_clients/_redis/_dataset_client.py +329 -0
- crawlee/storage_clients/_redis/_key_value_store_client.py +262 -0
- crawlee/storage_clients/_redis/_request_queue_client.py +583 -0
- crawlee/storage_clients/_redis/_storage_client.py +149 -0
- crawlee/storage_clients/_redis/_utils.py +23 -0
- crawlee/storage_clients/_redis/lua_scripts/atomic_bloom_add_requests.lua +36 -0
- crawlee/storage_clients/_redis/lua_scripts/atomic_fetch_request.lua +49 -0
- crawlee/storage_clients/_redis/lua_scripts/atomic_set_add_requests.lua +37 -0
- crawlee/storage_clients/_redis/lua_scripts/reclaim_stale_requests.lua +34 -0
- crawlee/storage_clients/_redis/py.typed +0 -0
- crawlee/storage_clients/_sql/__init__.py +6 -0
- crawlee/storage_clients/_sql/_client_mixin.py +385 -0
- crawlee/storage_clients/_sql/_dataset_client.py +310 -0
- crawlee/storage_clients/_sql/_db_models.py +268 -0
- crawlee/storage_clients/_sql/_key_value_store_client.py +300 -0
- crawlee/storage_clients/_sql/_request_queue_client.py +720 -0
- crawlee/storage_clients/_sql/_storage_client.py +282 -0
- crawlee/storage_clients/_sql/py.typed +0 -0
- crawlee/storage_clients/models.py +21 -14
- crawlee/storages/_base.py +5 -1
- crawlee/storages/_dataset.py +12 -2
- crawlee/storages/_key_value_store.py +17 -4
- crawlee/storages/_request_queue.py +13 -5
- crawlee/storages/_storage_instance_manager.py +196 -75
- crawlee/storages/_utils.py +11 -0
- {crawlee-0.6.13b15.dist-info → crawlee-1.3.1b3.dist-info}/METADATA +24 -19
- crawlee-1.3.1b3.dist-info/RECORD +207 -0
- {crawlee-0.6.13b15.dist-info → crawlee-1.3.1b3.dist-info}/WHEEL +1 -1
- crawlee/_utils/measure_time.py +0 -31
- crawlee-0.6.13b15.dist-info/RECORD +0 -183
- {crawlee-0.6.13b15.dist-info → crawlee-1.3.1b3.dist-info}/entry_points.txt +0 -0
- {crawlee-0.6.13b15.dist-info → crawlee-1.3.1b3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
from typing import Literal
|
|
5
|
+
|
|
6
|
+
from redis.asyncio import Redis
|
|
7
|
+
from typing_extensions import override
|
|
8
|
+
|
|
9
|
+
from crawlee._utils.docs import docs_group
|
|
10
|
+
from crawlee.configuration import Configuration
|
|
11
|
+
from crawlee.storage_clients._base import StorageClient
|
|
12
|
+
|
|
13
|
+
from ._dataset_client import RedisDatasetClient
|
|
14
|
+
from ._key_value_store_client import RedisKeyValueStoreClient
|
|
15
|
+
from ._request_queue_client import RedisRequestQueueClient
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@docs_group('Storage clients')
|
|
19
|
+
class RedisStorageClient(StorageClient):
|
|
20
|
+
"""Redis implementation of the storage client.
|
|
21
|
+
|
|
22
|
+
This storage client provides access to datasets, key-value stores, and request queues that persist data
|
|
23
|
+
to a Redis database v8.0+. Each storage type uses Redis-specific data structures and key patterns for
|
|
24
|
+
efficient storage and retrieval.
|
|
25
|
+
|
|
26
|
+
The client accepts either a Redis connection string or a pre-configured Redis client instance.
|
|
27
|
+
Exactly one of these parameters must be provided during initialization.
|
|
28
|
+
|
|
29
|
+
Storage types use the following Redis data structures:
|
|
30
|
+
- **Datasets**: Redis JSON arrays for item storage with metadata in JSON objects
|
|
31
|
+
- **Key-value stores**: Redis hashes for key-value pairs with separate metadata storage
|
|
32
|
+
- **Request queues**: Redis lists for FIFO queuing, hashes for request data and in-progress tracking,
|
|
33
|
+
and Bloom filters for request deduplication
|
|
34
|
+
|
|
35
|
+
Warning:
|
|
36
|
+
This is an experimental feature. The behavior and interface may change in future versions.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
*,
|
|
42
|
+
connection_string: str | None = None,
|
|
43
|
+
redis: Redis | None = None,
|
|
44
|
+
queue_dedup_strategy: Literal['default', 'bloom'] = 'default',
|
|
45
|
+
queue_bloom_error_rate: float = 1e-7,
|
|
46
|
+
) -> None:
|
|
47
|
+
"""Initialize the Redis storage client.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
connection_string: Redis connection string (e.g., "redis://localhost:6379").
|
|
51
|
+
Supports standard Redis URL format with optional database selection.
|
|
52
|
+
redis: Pre-configured Redis client instance.
|
|
53
|
+
queue_dedup_strategy: Strategy for request queue deduplication. Options are:
|
|
54
|
+
- 'default': Uses Redis sets for exact deduplication.
|
|
55
|
+
- 'bloom': Uses Redis Bloom filters for probabilistic deduplication with lower memory usage. When using
|
|
56
|
+
this approach, approximately 1 in 1e-7 requests will be falsely considered duplicate.
|
|
57
|
+
queue_bloom_error_rate: Desired false positive rate for Bloom filter deduplication. Only relevant if
|
|
58
|
+
`queue_dedup_strategy` is set to 'bloom'.
|
|
59
|
+
"""
|
|
60
|
+
if redis is None and connection_string is None:
|
|
61
|
+
raise ValueError('Either redis or connection_string must be provided.')
|
|
62
|
+
|
|
63
|
+
if redis is not None and connection_string is not None:
|
|
64
|
+
raise ValueError('Either redis or connection_string must be provided, not both.')
|
|
65
|
+
|
|
66
|
+
if isinstance(redis, Redis) and connection_string is None:
|
|
67
|
+
self._redis = redis
|
|
68
|
+
|
|
69
|
+
if isinstance(connection_string, str) and redis is None:
|
|
70
|
+
self._redis = Redis.from_url(connection_string)
|
|
71
|
+
|
|
72
|
+
self._redis: Redis # to help type checker
|
|
73
|
+
self._queue_dedup_strategy = queue_dedup_strategy
|
|
74
|
+
self._queue_bloom_error_rate = queue_bloom_error_rate
|
|
75
|
+
|
|
76
|
+
# Call the notification only once
|
|
77
|
+
warnings.warn(
|
|
78
|
+
(
|
|
79
|
+
'RedisStorageClient is experimental and its API, behavior, and key structure may change in future '
|
|
80
|
+
'releases.'
|
|
81
|
+
),
|
|
82
|
+
category=UserWarning,
|
|
83
|
+
stacklevel=2,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
@override
|
|
87
|
+
async def create_dataset_client(
|
|
88
|
+
self,
|
|
89
|
+
*,
|
|
90
|
+
id: str | None = None,
|
|
91
|
+
name: str | None = None,
|
|
92
|
+
alias: str | None = None,
|
|
93
|
+
configuration: Configuration | None = None,
|
|
94
|
+
) -> RedisDatasetClient:
|
|
95
|
+
configuration = configuration or Configuration.get_global_configuration()
|
|
96
|
+
|
|
97
|
+
client = await RedisDatasetClient.open(
|
|
98
|
+
id=id,
|
|
99
|
+
name=name,
|
|
100
|
+
alias=alias,
|
|
101
|
+
redis=self._redis,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
await self._purge_if_needed(client, configuration)
|
|
105
|
+
return client
|
|
106
|
+
|
|
107
|
+
@override
|
|
108
|
+
async def create_kvs_client(
|
|
109
|
+
self,
|
|
110
|
+
*,
|
|
111
|
+
id: str | None = None,
|
|
112
|
+
name: str | None = None,
|
|
113
|
+
alias: str | None = None,
|
|
114
|
+
configuration: Configuration | None = None,
|
|
115
|
+
) -> RedisKeyValueStoreClient:
|
|
116
|
+
configuration = configuration or Configuration.get_global_configuration()
|
|
117
|
+
|
|
118
|
+
client = await RedisKeyValueStoreClient.open(
|
|
119
|
+
id=id,
|
|
120
|
+
name=name,
|
|
121
|
+
alias=alias,
|
|
122
|
+
redis=self._redis,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
await self._purge_if_needed(client, configuration)
|
|
126
|
+
return client
|
|
127
|
+
|
|
128
|
+
@override
|
|
129
|
+
async def create_rq_client(
|
|
130
|
+
self,
|
|
131
|
+
*,
|
|
132
|
+
id: str | None = None,
|
|
133
|
+
name: str | None = None,
|
|
134
|
+
alias: str | None = None,
|
|
135
|
+
configuration: Configuration | None = None,
|
|
136
|
+
) -> RedisRequestQueueClient:
|
|
137
|
+
configuration = configuration or Configuration.get_global_configuration()
|
|
138
|
+
|
|
139
|
+
client = await RedisRequestQueueClient.open(
|
|
140
|
+
id=id,
|
|
141
|
+
name=name,
|
|
142
|
+
alias=alias,
|
|
143
|
+
redis=self._redis,
|
|
144
|
+
dedup_strategy=self._queue_dedup_strategy,
|
|
145
|
+
bloom_error_rate=self._queue_bloom_error_rate,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
await self._purge_if_needed(client, configuration)
|
|
149
|
+
return client
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from collections.abc import Awaitable
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import TypeVar, overload
|
|
4
|
+
|
|
5
|
+
T = TypeVar('T')
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@overload
|
|
9
|
+
async def await_redis_response(response: Awaitable[T]) -> T: ...
|
|
10
|
+
@overload
|
|
11
|
+
async def await_redis_response(response: T) -> T: ...
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def await_redis_response(response: Awaitable[T] | T) -> T:
|
|
15
|
+
"""Solve the problem of ambiguous typing for redis."""
|
|
16
|
+
return await response if isinstance(response, Awaitable) else response
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def read_lua_script(script_name: str) -> str:
|
|
20
|
+
"""Read a Lua script from a file."""
|
|
21
|
+
file_path = Path(__file__).parent / 'lua_scripts' / script_name
|
|
22
|
+
with file_path.open(mode='r', encoding='utf-8') as file:
|
|
23
|
+
return file.read()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
local added_filter_key = KEYS[1]
|
|
2
|
+
local queue_key = KEYS[2]
|
|
3
|
+
local data_key = KEYS[3]
|
|
4
|
+
|
|
5
|
+
local forefront = ARGV[1] == '1'
|
|
6
|
+
local unique_keys = cjson.decode(ARGV[2])
|
|
7
|
+
local requests_data = cjson.decode(ARGV[3])
|
|
8
|
+
|
|
9
|
+
-- Add and check which unique keys are actually new using Bloom filter
|
|
10
|
+
local bf_results = redis.call('bf.madd', added_filter_key, unpack(unique_keys))
|
|
11
|
+
|
|
12
|
+
local actually_added = {}
|
|
13
|
+
local hset_args = {}
|
|
14
|
+
|
|
15
|
+
-- Process the results
|
|
16
|
+
for i, unique_key in ipairs(unique_keys) do
|
|
17
|
+
if bf_results[i] == 1 then
|
|
18
|
+
-- This key was added by us (did not exist before)
|
|
19
|
+
table.insert(hset_args, unique_key)
|
|
20
|
+
table.insert(hset_args, requests_data[unique_key])
|
|
21
|
+
table.insert(actually_added, unique_key)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
-- Add only those that are actually new
|
|
26
|
+
if #actually_added > 0 then
|
|
27
|
+
redis.call('hset', data_key, unpack(hset_args))
|
|
28
|
+
|
|
29
|
+
if forefront then
|
|
30
|
+
redis.call('lpush', queue_key, unpack(actually_added))
|
|
31
|
+
else
|
|
32
|
+
redis.call('rpush', queue_key, unpack(actually_added))
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
return cjson.encode(actually_added)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
local queue_key = KEYS[1]
|
|
2
|
+
local in_progress_key = KEYS[2]
|
|
3
|
+
local data_key = KEYS[3]
|
|
4
|
+
local client_id = ARGV[1]
|
|
5
|
+
local blocked_until_timestamp = ARGV[2]
|
|
6
|
+
local batch_size = tonumber(ARGV[3])
|
|
7
|
+
|
|
8
|
+
-- Pop batch unique_key from queue
|
|
9
|
+
local batch_result = redis.call('LMPOP', 1, queue_key, 'LEFT', 'COUNT', batch_size)
|
|
10
|
+
if not batch_result then
|
|
11
|
+
return nil
|
|
12
|
+
end
|
|
13
|
+
local unique_keys = batch_result[2]
|
|
14
|
+
|
|
15
|
+
-- Get requests data
|
|
16
|
+
local requests_data = redis.call('HMGET', data_key, unpack(unique_keys))
|
|
17
|
+
if not requests_data then
|
|
18
|
+
-- Data missing, skip this request
|
|
19
|
+
return nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
-- Prepare results and update in_progress
|
|
23
|
+
local final_result = {}
|
|
24
|
+
local in_progress_hmset = {}
|
|
25
|
+
local pending_decrement = 0
|
|
26
|
+
local in_progress_data = cjson.encode({
|
|
27
|
+
client_id = client_id,
|
|
28
|
+
blocked_until_timestamp = tonumber(blocked_until_timestamp)
|
|
29
|
+
})
|
|
30
|
+
for i = 1, #unique_keys do
|
|
31
|
+
local unique_key = unique_keys[i]
|
|
32
|
+
local request_data = requests_data[i]
|
|
33
|
+
|
|
34
|
+
if request_data then
|
|
35
|
+
-- Add to in_progress hash
|
|
36
|
+
table.insert(in_progress_hmset, unique_key)
|
|
37
|
+
table.insert(in_progress_hmset, in_progress_data)
|
|
38
|
+
|
|
39
|
+
table.insert(final_result, request_data)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
-- Update in_progress hash
|
|
44
|
+
if #in_progress_hmset > 0 then
|
|
45
|
+
redis.call('HMSET', in_progress_key, unpack(in_progress_hmset))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
-- Return result with requests data
|
|
49
|
+
return final_result
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
local added_filter_key = KEYS[1]
|
|
2
|
+
local queue_key = KEYS[2]
|
|
3
|
+
local data_key = KEYS[3]
|
|
4
|
+
|
|
5
|
+
local forefront = ARGV[1] == '1'
|
|
6
|
+
local unique_keys = cjson.decode(ARGV[2])
|
|
7
|
+
local requests_data = cjson.decode(ARGV[3])
|
|
8
|
+
|
|
9
|
+
-- Add and check which unique keys are actually new using Redis set
|
|
10
|
+
local actually_added = {}
|
|
11
|
+
local hset_args = {}
|
|
12
|
+
|
|
13
|
+
-- Process each unique key
|
|
14
|
+
for _, unique_key in ipairs(unique_keys) do
|
|
15
|
+
-- Try to add the key to the set, returns 1 if added, 0 if already existed
|
|
16
|
+
local set_result = redis.call('sadd', added_filter_key, unique_key)
|
|
17
|
+
|
|
18
|
+
if set_result == 1 then
|
|
19
|
+
-- This key was added by us (did not exist before)
|
|
20
|
+
table.insert(hset_args, unique_key)
|
|
21
|
+
table.insert(hset_args, requests_data[unique_key])
|
|
22
|
+
table.insert(actually_added, unique_key)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
-- Add only those that are actually new
|
|
27
|
+
if #actually_added > 0 then
|
|
28
|
+
redis.call('hset', data_key, unpack(hset_args))
|
|
29
|
+
|
|
30
|
+
if forefront then
|
|
31
|
+
redis.call('lpush', queue_key, unpack(actually_added))
|
|
32
|
+
else
|
|
33
|
+
redis.call('rpush', queue_key, unpack(actually_added))
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
return cjson.encode(actually_added)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
local in_progress_key = KEYS[1]
|
|
2
|
+
local queue_key = KEYS[2]
|
|
3
|
+
local data_key = KEYS[3]
|
|
4
|
+
local current_time = tonumber(ARGV[1])
|
|
5
|
+
|
|
6
|
+
local max_reclaim = 1000
|
|
7
|
+
|
|
8
|
+
local cursor = "0"
|
|
9
|
+
local count = 0
|
|
10
|
+
|
|
11
|
+
repeat
|
|
12
|
+
local result = redis.call('hscan', in_progress_key, cursor, 'COUNT', 100)
|
|
13
|
+
cursor = result[1]
|
|
14
|
+
local entries = result[2]
|
|
15
|
+
|
|
16
|
+
for i = 1, #entries, 2 do
|
|
17
|
+
if count >= max_reclaim then
|
|
18
|
+
break
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
local unique_key = entries[i]
|
|
22
|
+
local data = cjson.decode(entries[i + 1])
|
|
23
|
+
|
|
24
|
+
-- Check if timed out
|
|
25
|
+
if current_time > data.blocked_until_timestamp then
|
|
26
|
+
-- Atomically remove from in_progress and add back to queue
|
|
27
|
+
redis.call('hdel', in_progress_key, unique_key)
|
|
28
|
+
redis.call('rpush', queue_key, unique_key)
|
|
29
|
+
count = count + 1
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
until cursor == "0" or count >= max_reclaim
|
|
33
|
+
|
|
34
|
+
return count
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from ._dataset_client import SqlDatasetClient
|
|
2
|
+
from ._key_value_store_client import SqlKeyValueStoreClient
|
|
3
|
+
from ._request_queue_client import SqlRequestQueueClient
|
|
4
|
+
from ._storage_client import SqlStorageClient
|
|
5
|
+
|
|
6
|
+
__all__ = ['SqlDatasetClient', 'SqlKeyValueStoreClient', 'SqlRequestQueueClient', 'SqlStorageClient']
|