Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Fixed several minor issues in retryable requests #373

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an upper limit here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to avoid potential issues in the future, we can change it when the new version will be released

],
extras_require={
'qa': [
Expand Down
Loading