GRequests monkey patch warning

Tags: , ,

I get the following warning each time , though the module works as expected :

/usr/local/lib/python3.7/site-packages/ MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See Modules that had direct imports (NOT patched): ['urllib3.util (/usr/local/lib/python3.7/site-packages/urllib3/util/', 'urllib3.contrib.pyopenssl (/usr/local/lib/python3.7/site-packages/urllib3/contrib/']. 
  curious_george.patch_all(thread=False, select=False)

I tried the workaround mentioned at this github issue but that doesn’t work.

How to get rid of this warning ?


For grequests you would need to add the following code before other modules try to import / load gevent and ssl:

from gevent import monkey as curious_george
curious_george.patch_all(thread=False, select=False)

Source: stackoverflow