Skip to content

Commit 226e499

Browse files
committed
refactor: Use DeprecationWarning for deprecated request queue arguments
1 parent dc6cf5c commit 226e499

1 file changed

Lines changed: 37 additions & 9 deletions

File tree

src/apify_client/clients/resource_clients/request_queue.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

33
import asyncio
4-
import logging
54
import math
5+
import warnings
66
from collections.abc import Iterable
77
from queue import Queue
88
from typing import TYPE_CHECKING, Any, TypedDict
@@ -23,8 +23,6 @@
2323

2424
from apify_shared.consts import StorageGeneralAccess
2525

26-
logger = logging.getLogger(__name__)
27-
2826
_RQ_MAX_REQUESTS_PER_BATCH = 25
2927
_MAX_PAYLOAD_SIZE_BYTES = 9 * 1024 * 1024 # 9 MB
3028
_SAFETY_BUFFER_PERCENT = 0.01 / 100 # 0.01%
@@ -311,9 +309,17 @@ def batch_add_requests(
311309
Result containing lists of processed and unprocessed requests.
312310
"""
313311
if max_unprocessed_requests_retries:
314-
logger.warning('`max_unprocessed_requests_retries` is deprecated and not used anymore.')
312+
warnings.warn(
313+
'`max_unprocessed_requests_retries` is deprecated and not used anymore.',
314+
DeprecationWarning,
315+
stacklevel=2,
316+
)
315317
if min_delay_between_unprocessed_requests_retries:
316-
logger.warning('`min_delay_between_unprocessed_requests_retries` is deprecated and not used anymore.')
318+
warnings.warn(
319+
'`min_delay_between_unprocessed_requests_retries` is deprecated and not used anymore.',
320+
DeprecationWarning,
321+
stacklevel=2,
322+
)
317323

318324
if max_parallel != 1:
319325
raise NotImplementedError('max_parallel is only supported in async client')
@@ -393,8 +399,15 @@ def list_requests(
393399
394400
Args:
395401
limit: How many requests to retrieve.
396-
exclusive_start_id: All requests up to this one (including) are skipped from the result.
402+
exclusive_start_id: Deprecated argument. Will be removed in next major release.
397403
"""
404+
if exclusive_start_id is not None:
405+
warnings.warn(
406+
'`exclusive_start_id` is deprecated for paginating requests.',
407+
DeprecationWarning,
408+
stacklevel=2,
409+
)
410+
398411
request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key)
399412

400413
response = self.http_client.call(
@@ -738,9 +751,17 @@ async def batch_add_requests(
738751
Result containing lists of processed and unprocessed requests.
739752
"""
740753
if max_unprocessed_requests_retries:
741-
logger.warning('`max_unprocessed_requests_retries` is deprecated and not used anymore.')
754+
warnings.warn(
755+
'`max_unprocessed_requests_retries` is deprecated and not used anymore.',
756+
DeprecationWarning,
757+
stacklevel=2,
758+
)
742759
if min_delay_between_unprocessed_requests_retries:
743-
logger.warning('`min_delay_between_unprocessed_requests_retries` is deprecated and not used anymore.')
760+
warnings.warn(
761+
'`min_delay_between_unprocessed_requests_retries` is deprecated and not used anymore.',
762+
DeprecationWarning,
763+
stacklevel=2,
764+
)
744765

745766
tasks = set[asyncio.Task]()
746767
queue: asyncio.Queue[Iterable[dict]] = asyncio.Queue()
@@ -821,8 +842,15 @@ async def list_requests(
821842
822843
Args:
823844
limit: How many requests to retrieve.
824-
exclusive_start_id: All requests up to this one (including) are skipped from the result.
845+
exclusive_start_id: Deprecated argument. Will be removed in next major release.
825846
"""
847+
if exclusive_start_id is not None:
848+
warnings.warn(
849+
'`exclusive_start_id` is deprecated for paginating requests.',
850+
DeprecationWarning,
851+
stacklevel=2,
852+
)
853+
826854
request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key)
827855

828856
response = await self.http_client.call(

0 commit comments

Comments
 (0)