-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
adding warning when requests_futures isnt installed #1863
Open
RichieCahill
wants to merge
7
commits into
pycontribs:main
Choose a base branch
from
RichieCahill:feature/adding-warning-when-requests_futures-isnt-installed
base: main
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 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74f6490
adding warning when requests_futures isnt installed
RichieCahill e19640d
updated afters dimitarOnGithub input
RichieCahill 4fe96c9
updated with adehad suggestions
RichieCahill 797ec7c
fixed bug
RichieCahill 34ae65e
fixed bug
RichieCahill 8c0af70
Merge branch 'main' into feature/adding-warning-when-requests_futures…
RichieCahill 66f9d55
Merge branch 'main' into feature/adding-warning-when-requests_futures…
RichieCahill 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -573,7 +573,22 @@ def __init__( | |||||
|
||||||
if server: | ||||||
options["server"] = server | ||||||
|
||||||
options["async_class"] = None | ||||||
if async_: | ||||||
if self._options["async"]: | ||||||
try: | ||||||
from requests_futures.sessions import FuturesSession | ||||||
|
||||||
options["async_class"] = FuturesSession | ||||||
except ImportError: | ||||||
msg = ( | ||||||
"async option requires requests-futures to be installed. " | ||||||
"falling back to synchronous implementation." | ||||||
) | ||||||
warnings.warn(msg) | ||||||
pass | ||||||
|
||||||
options["async"] = async_ | ||||||
options["async_workers"] = async_workers | ||||||
|
||||||
|
@@ -790,16 +805,6 @@ def _fetch_pages( | |||||
Returns: | ||||||
ResultList | ||||||
""" | ||||||
async_workers = None | ||||||
async_class = None | ||||||
if self._options["async"]: | ||||||
try: | ||||||
from requests_futures.sessions import FuturesSession | ||||||
|
||||||
async_class = FuturesSession | ||||||
except ImportError: | ||||||
pass | ||||||
async_workers = self._options.get("async_workers") | ||||||
|
||||||
def json_params() -> dict[str, Any]: | ||||||
# passing through json.dumps and json.loads ensures json | ||||||
|
@@ -847,14 +852,16 @@ def json_params() -> dict[str, Any]: | |||||
page_size, | ||||||
) | ||||||
page_start = (startAt or start_at_from_response or 0) + page_size | ||||||
async_class = self._options["async_class"] | ||||||
if ( | ||||||
async_class is not None | ||||||
and not is_last | ||||||
and (total is not None and len(items) < total) | ||||||
): | ||||||
async_fetches = [] | ||||||
future_session = async_class( | ||||||
session=self._session, max_workers=async_workers | ||||||
session=self._session, | ||||||
max_workers=self._options["async_workers"], | ||||||
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. Just to preserve the original code I would suggest keep this as
Suggested change
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. what value dose preserve the original code add in this case? |
||||||
) | ||||||
for start_index in range(page_start, total, page_size): | ||||||
page_params = json_params() | ||||||
|
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.
My preference would be to:
FutureSession
asNone
if it is not imported or have a boolean variable, eg._has_async_support
.Furthermore I would augment this warning message with a suggestion of how to install this extra requirement, as we do have this as an extra, it may be appropriate to say,
this can be installed using the 'async' extra, e.g. pip install jira[async]
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.
ive updated the code based on your suggestion. Im unclear on what 3 means.