Skip to content

Commit

Permalink
[fix] Fixed several minor issues in retryable requests
Browse files Browse the repository at this point in the history
- we need to ensure a recent version of requests is installed
- docs had several mistakes
- some code was repeated twice in the function definition
  • Loading branch information
nemesifier committed Mar 14, 2024
1 parent 4719e07 commit 81d8e7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,8 @@ Usage:
but not for complex background tasks which can take a long time to execute
(eg: firmware upgrades, network operations with retry mechanisms).

``openwisp_utils.tasks.retryable_requests``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``openwisp_utils.utils.retryable_request``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A utility function for making HTTP requests with built-in retry logic.
This function is useful for handling transient errors encountered during HTTP
Expand All @@ -1361,7 +1361,7 @@ Usage:

.. code-block:: python
from your_module import retryable_request
from openwisp_utils.utils import retryable_request
response = retryable_request(
method='GET',
Expand Down
10 changes: 0 additions & 10 deletions openwisp_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,6 @@ def retryable_request(
backoff_jitter=backoff_jitter,
)
)
retry_kwargs = retry_kwargs or {}
retry_kwargs.update(
dict(
total=max_retries,
backoff_factor=backoff_factor,
backoff_jitter=backoff_jitter,
status_forcelist=status_forcelist,
allowed_methods=allowed_methods,
)
)
request_session = requests.Session()
retries = Retry(**retry_kwargs)
request_session.mount('https://', HTTPAdapter(max_retries=retries))
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
'django-compress-staticfiles~=1.0.1b',
'django-admin-autocomplete-filter~=0.7.1',
'swapper~=1.3.0',
# allow wider range here to avoid interfering with other modules
'requests>=2.31.0,<3.0.0',
],
extras_require={
'qa': [
Expand Down

0 comments on commit 81d8e7a

Please sign in to comment.