-
Notifications
You must be signed in to change notification settings - Fork 991
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
Keep sessions around between each ConanRequester #17455
Open
AbrilRBS
wants to merge
10
commits into
conan-io:develop2
Choose a base branch
from
AbrilRBS:ar/keep-sessions-around
base: develop2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
83adac6
Keep sessions around between each ConanRequester
AbrilRBS e26a354
Patch new cached value on ConanRequester tests
AbrilRBS 0dba33d
Modify adapter as needed
AbrilRBS ab839d8
Fix tests
AbrilRBS 127fc08
Name
AbrilRBS 065926d
Update conans/client/rest/conan_requester.py
AbrilRBS 7057bd0
Refactor requester tests
AbrilRBS 7a8b44c
Merge branch 'develop2' into ar/keep-sessions-around
AbrilRBS 44f90cb
Reinit is not part of this PR
AbrilRBS e9ac51a
Refactor request usage out of app
AbrilRBS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,18 +99,12 @@ def add_auth(self, url, kwargs): | |
class ConanRequester: | ||
|
||
def __init__(self, config, cache_folder=None): | ||
# TODO: Make all this lazy, to avoid fully configuring Requester, for every api call | ||
# even if it doesn't use it | ||
# FIXME: Trick for testing when requests is mocked | ||
if hasattr(requests, "Session"): | ||
self._http_requester = requests.Session() | ||
adapter = HTTPAdapter(max_retries=self._get_retries(config)) | ||
self._http_requester.mount("http://", adapter) | ||
self._http_requester.mount("https://", adapter) | ||
else: | ||
self._http_requester = requests | ||
|
||
self._url_creds = _SourceURLCredentials(cache_folder) | ||
self._max_retries = config.get("core.net.http:max_retries", default=2, check_type=int) | ||
AbrilRBS marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
self._http_requester = requests.Session() | ||
_adapter = HTTPAdapter(max_retries=self._get_retries()) | ||
self._http_requester.mount("http://", _adapter) | ||
self._http_requester.mount("https://", _adapter) | ||
self._timeout = config.get("core.net.http:timeout", default=DEFAULT_TIMEOUT) | ||
self._no_proxy_match = config.get("core.net.http:no_proxy_match", check_type=list) | ||
self._proxies = config.get("core.net.http:proxies") | ||
|
@@ -123,9 +117,8 @@ def __init__(self, config, cache_folder=None): | |
platform.machine()]) | ||
self._user_agent = "Conan/%s (%s)" % (__version__, platform_info) | ||
|
||
@staticmethod | ||
def _get_retries(config): | ||
retry = config.get("core.net.http:max_retries", default=2, check_type=int) | ||
def _get_retries(self): | ||
retry = self._max_retries | ||
if retry == 0: | ||
return 0 | ||
retry_status_code_set = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to design, implement and document properly the "invalidating" and reloading of global.conf, like the requester will not get new conf after a
config install
. I think this is perfectly good as default, but the "invalidation" should also be doable and documented. I'll create a ticket for this later.