From f9f3def2fe335325f32aac9f2045c3fecf955945 Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Sat, 17 Aug 2024 10:55:24 -0700 Subject: [PATCH] Monkey-patch for grequests in pittapi __init__ (#197) 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: https://github.com/spyoungtech/grequests/issues/150 https://github.com/gevent/gevent/issues/1016 --- pittapi/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pittapi/__init__.py b/pittapi/__init__.py index f2bc29c..493accb 100644 --- a/pittapi/__init__.py +++ b/pittapi/__init__.py @@ -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