9

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

/usr/local/lib/python3.7/site-packages/grequests.py:21: 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 https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['urllib3.util (/usr/local/lib/python3.7/site-packages/urllib3/util/__init__.py)', 'urllib3.contrib.pyopenssl (/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py)']. 
  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 ?

Sajith Herath
  • 1,002
  • 2
  • 11
  • 24
Ram K
  • 1,746
  • 2
  • 14
  • 23

2 Answers2

14

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)
Chris
  • 524
  • 7
  • 6
4

see grequests documentation: https://github.com/spyoungtech/grequests

GOOD:

import grequests 

import requests

BAD:

import requests 

import grequests
n4321d
  • 1,059
  • 2
  • 12
  • 31