Including the 'jenkinsapi' package in a project breaks retries in the 'requests' library in some cases
ISSUE TYPE
- Bug Report
Jenkinsapi VERSION
0.3.11 / latest 'master' branch
Jenkins VERSION
Any
SUMMARY
The line here:
https://github.com/pycontribs/jenkinsapi/blob/master/jenkinsapi/utils/requester.py#L26
overrides DEFAULT_RETRIES value. However the requests library has changed and that no longer sets the default retry value globally. Now, it causes a breakage with the requests library for other code that uses the jenkinsapi package.
There is a problematic interaction with the code here: https://github.com/psf/requests/blob/master/requests/adapters.py#L116
if max_retries == DEFAULT_RETRIES:
self.max_retries = Retry(0, read=False)
else:
self.max_retries = Retry.from_int(max_retries)
The requests library expects this value to be 0. By overriding it with 5, it causes any HTTPAdapter created with max_retires set to 5 is will actually be created with a retry count of 0.
EXPECTED RESULTS
If I write other code that sets a max_retries value of 5 using the HTTPAdapter class, it should use that value.
ACTUAL RESULTS
Setting a max_retries value of 5 in any other code in a python project that includes the jenkinsapi package will disable retries.
USEFUL INFORMATION
The fix is to delete this line (https://github.com/pycontribs/jenkinsapi/blob/master/jenkinsapi/utils/requester.py#L26), it is not doing anything anymore except causing this bug. The functionality for setting retries was already implemented into master in PR #739 .