|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import asyncio |
4 | | -import logging |
5 | 4 | import math |
| 5 | +import warnings |
6 | 6 | from collections.abc import Iterable |
7 | 7 | from queue import Queue |
8 | 8 | from typing import TYPE_CHECKING, Any, TypedDict |
|
23 | 23 |
|
24 | 24 | from apify_shared.consts import StorageGeneralAccess |
25 | 25 |
|
26 | | -logger = logging.getLogger(__name__) |
27 | | - |
28 | 26 | _RQ_MAX_REQUESTS_PER_BATCH = 25 |
29 | 27 | _MAX_PAYLOAD_SIZE_BYTES = 9 * 1024 * 1024 # 9 MB |
30 | 28 | _SAFETY_BUFFER_PERCENT = 0.01 / 100 # 0.01% |
@@ -311,9 +309,17 @@ def batch_add_requests( |
311 | 309 | Result containing lists of processed and unprocessed requests. |
312 | 310 | """ |
313 | 311 | 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 | + ) |
315 | 317 | 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 | + ) |
317 | 323 |
|
318 | 324 | if max_parallel != 1: |
319 | 325 | raise NotImplementedError('max_parallel is only supported in async client') |
@@ -393,8 +399,15 @@ def list_requests( |
393 | 399 |
|
394 | 400 | Args: |
395 | 401 | 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. |
397 | 403 | """ |
| 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 | + |
398 | 411 | request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key) |
399 | 412 |
|
400 | 413 | response = self.http_client.call( |
@@ -738,9 +751,17 @@ async def batch_add_requests( |
738 | 751 | Result containing lists of processed and unprocessed requests. |
739 | 752 | """ |
740 | 753 | 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 | + ) |
742 | 759 | 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 | + ) |
744 | 765 |
|
745 | 766 | tasks = set[asyncio.Task]() |
746 | 767 | queue: asyncio.Queue[Iterable[dict]] = asyncio.Queue() |
@@ -821,8 +842,15 @@ async def list_requests( |
821 | 842 |
|
822 | 843 | Args: |
823 | 844 | 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. |
825 | 846 | """ |
| 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 | + |
826 | 854 | request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key) |
827 | 855 |
|
828 | 856 | response = await self.http_client.call( |
|
0 commit comments