|
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% |
@@ -304,16 +302,25 @@ def batch_add_requests( |
304 | 302 | max_parallel: Specifies the maximum number of parallel tasks for API calls. This is only applicable |
305 | 303 | to the async client. For the sync client, this value must be set to 1, as parallel execution |
306 | 304 | is not supported. |
307 | | - max_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. |
308 | | - min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. |
| 305 | + max_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. |
| 306 | + min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. |
309 | 307 |
|
310 | 308 | Returns: |
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 | + 'The `max_unprocessed_requests_retries` argument is deprecated and will be removed in v3.', |
| 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 | + 'The `min_delay_between_unprocessed_requests_retries` argument is deprecated and will be removed ' |
| 320 | + 'in v3.', |
| 321 | + DeprecationWarning, |
| 322 | + stacklevel=2, |
| 323 | + ) |
317 | 324 |
|
318 | 325 | if max_parallel != 1: |
319 | 326 | raise NotImplementedError('max_parallel is only supported in async client') |
@@ -393,8 +400,15 @@ def list_requests( |
393 | 400 |
|
394 | 401 | Args: |
395 | 402 | limit: How many requests to retrieve. |
396 | | - exclusive_start_id: All requests up to this one (including) are skipped from the result. |
| 403 | + exclusive_start_id: Deprecated argument. Will be removed in v3. |
397 | 404 | """ |
| 405 | + if exclusive_start_id is not None: |
| 406 | + warnings.warn( |
| 407 | + 'The `exclusive_start_id` argument is deprecated and will be removed in v3.', |
| 408 | + DeprecationWarning, |
| 409 | + stacklevel=2, |
| 410 | + ) |
| 411 | + |
398 | 412 | request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key) |
399 | 413 |
|
400 | 414 | response = self.http_client.call( |
@@ -731,16 +745,25 @@ async def batch_add_requests( |
731 | 745 | max_parallel: Specifies the maximum number of parallel tasks for API calls. This is only applicable |
732 | 746 | to the async client. For the sync client, this value must be set to 1, as parallel execution |
733 | 747 | is not supported. |
734 | | - max_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. |
735 | | - min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in next major release. |
| 748 | + max_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. |
| 749 | + min_delay_between_unprocessed_requests_retries: Deprecated argument. Will be removed in v3. |
736 | 750 |
|
737 | 751 | Returns: |
738 | 752 | Result containing lists of processed and unprocessed requests. |
739 | 753 | """ |
740 | 754 | if max_unprocessed_requests_retries: |
741 | | - logger.warning('`max_unprocessed_requests_retries` is deprecated and not used anymore.') |
| 755 | + warnings.warn( |
| 756 | + 'The `max_unprocessed_requests_retries` argument is deprecated and will be removed in v3.', |
| 757 | + DeprecationWarning, |
| 758 | + stacklevel=2, |
| 759 | + ) |
742 | 760 | if min_delay_between_unprocessed_requests_retries: |
743 | | - logger.warning('`min_delay_between_unprocessed_requests_retries` is deprecated and not used anymore.') |
| 761 | + warnings.warn( |
| 762 | + 'The `min_delay_between_unprocessed_requests_retries` argument is deprecated and will be removed ' |
| 763 | + 'in v3.', |
| 764 | + DeprecationWarning, |
| 765 | + stacklevel=2, |
| 766 | + ) |
744 | 767 |
|
745 | 768 | tasks = set[asyncio.Task]() |
746 | 769 | queue: asyncio.Queue[Iterable[dict]] = asyncio.Queue() |
@@ -821,8 +844,15 @@ async def list_requests( |
821 | 844 |
|
822 | 845 | Args: |
823 | 846 | limit: How many requests to retrieve. |
824 | | - exclusive_start_id: All requests up to this one (including) are skipped from the result. |
| 847 | + exclusive_start_id: Deprecated argument. Will be removed in v3. |
825 | 848 | """ |
| 849 | + if exclusive_start_id is not None: |
| 850 | + warnings.warn( |
| 851 | + 'The `exclusive_start_id` argument is deprecated and will be removed in v3.', |
| 852 | + DeprecationWarning, |
| 853 | + stacklevel=2, |
| 854 | + ) |
| 855 | + |
826 | 856 | request_params = self._params(limit=limit, exclusiveStartId=exclusive_start_id, clientKey=self.client_key) |
827 | 857 |
|
828 | 858 | response = await self.http_client.call( |
|
0 commit comments