GRequests 猴子补丁警告
GRequests monkey patch warning
我每次都收到以下警告,尽管模块按预期工作:
/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)
我尝试了 this github issue 中提到的解决方法,但它不起作用。
如何摆脱这个警告?
对于 grequests,您需要在其他模块尝试导入/加载 gevent 和 ssl 之前添加以下代码:
from gevent import monkey as curious_george
curious_george.patch_all(thread=False, select=False)
我每次都收到以下警告,尽管模块按预期工作:
/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)
我尝试了 this github issue 中提到的解决方法,但它不起作用。
如何摆脱这个警告?
对于 grequests,您需要在其他模块尝试导入/加载 gevent 和 ssl 之前添加以下代码:
from gevent import monkey as curious_george
curious_george.patch_all(thread=False, select=False)