Ram K
Ram K

Reputation: 1785

GRequests monkey patch warning

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 ?

Upvotes: 10

Views: 12813

Answers (2)

Ordit Gross
Ordit Gross

Reputation: 81

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

GOOD:

import grequests 

import requests

BAD:

import requests 

import grequests

Upvotes: 7

Chris
Chris

Reputation: 554

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)

Upvotes: 15

Related Questions