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

If gevent is activated (using monkey_patch) we have to use grequests instead of requests. #22

Merged
merged 5 commits into from
Jul 22, 2015

Conversation

Natim
Copy link
Collaborator

@Natim Natim commented Mar 26, 2015

This fix works, but I am not a fan yet. I will try to figure out how we can check if gevent is activated instead.

@almet
Copy link
Contributor

almet commented Mar 26, 2015

As simple as that 💃

@rfk
Copy link
Contributor

rfk commented Mar 26, 2015

I'm not comfortable with this happening automagically. How would you feel about exposing an explicit function that the app can call to enable this, e.g. fxa.monkey_patch_for_gevent()?

@rfk
Copy link
Contributor

rfk commented Mar 26, 2015

(Although this is by far the most considerate automagical gevent detection I've ever seen, thank you!)

@Natim
Copy link
Collaborator Author

Natim commented Mar 26, 2015

I will try to pass the right session to the apiclient, how would this function work?

@rfk
Copy link
Contributor

rfk commented Mar 26, 2015

just comment out the lines, which would keep the context in place.

We could copy what you've got at the top-level there into a function, and have it reach into each PyFxA sub-module and replace requests with grequests.

@Natim Natim changed the title If gevent is activated (using monkey_patch) we have to use gerequests instead of requests. If gevent is activated (using monkey_patch) we have to use grequests instead of requests. Mar 27, 2015
@Natim
Copy link
Collaborator Author

Natim commented Jul 21, 2015

ping @rfk



from requests.packages import urllib3
urllib3.disable_warnings()
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry about accidentally disabling these in production by importing fxa.tests without realizing it. Can we put this into a module-level setup/teardown function so it only applies for the duration of the tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Even if it was disabled in production it should not be a problem since it is only a warning related to the Python version.
Since it is used in every tests, I wouldn't add this in every testcase setUp. Should I create a BaseTestCase and inherit every FxA TestCase with it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Concretely, my concern is if we accidentally disable a warning about insecure SSL certificate checking or some other security-sensitive matter. If that's not a possibility then I'm happy to leave it as global disable. Maybe we can only disable this specific warning rather than all warnings?

Otherwise BaseTestCase seems like a good approach, but I don't want to create too much busywork for future test writers :-(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to the documentation you are right: https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning

Maybe we can setup PyOpenSSL usage for PyFxA as described here: https://urllib3.readthedocs.org/en/latest/security.html#pyopenssl

@rfk
Copy link
Contributor

rfk commented Jul 22, 2015

Otherwise LGTM!

@Natim
Copy link
Collaborator Author

Natim commented Jul 22, 2015

Updated.

Natim added a commit that referenced this pull request Jul 22, 2015
If gevent is activated (using monkey_patch) we have to use grequests instead of requests.
@Natim Natim merged commit 0a17d6f into master Jul 22, 2015
@Natim Natim deleted the use_gevent_if_present branch July 23, 2015 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants