Skip to content

Commit

Permalink
Monkey-patch for grequests in pittapi __init__ (#197)
Browse files Browse the repository at this point in the history
The grequests package monkey-patches ssl upon import, but this must be
done before all other imports or else we get a MonkeyPatchWarning or a
RecursionError.

References:
spyoungtech/grequests#150
gevent/gevent#1016
  • Loading branch information
tianyizheng02 authored Aug 17, 2024
1 parent 684d056 commit f9f3def
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pittapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""

# grequests monkey-patches ssl, but this must be done before all other imports,
# or else we may get a MonkeyPatchWarning or a RecursionError
# See https://github.com/spyoungtech/grequests/issues/150 and https://github.com/gevent/gevent/issues/1016
from gevent import monkey

monkey.patch_all(thread=False, select=False)

import urllib3
from urllib3.exceptions import InsecureRequestWarning

Expand Down

0 comments on commit f9f3def

Please sign in to comment.