每次我都会收到以下警告,尽管模块按预期工作:
/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)我尝试了在这个github问题上提到的解决方法,但这不起作用。
如何消除这个警告?
发布于 2019-07-25 08:13:38
对于grequests,在其他模块尝试导入/加载gevent和ssl之前,您需要添加以下代码:
from gevent import monkey as curious_george
curious_george.patch_all(thread=False, select=False)发布于 2022-08-12 10:50:01
请参阅grequests:https://github.com/spyoungtech/grequests
好:
import grequests
import requests坏:
import requests
import grequestshttps://stackoverflow.com/questions/56309763
复制相似问题