GRequests猴子补丁警告

时间:2019-05-26 00:31:10

标签: python python-3.x grequests

尽管模块按预期工作,但每次都会收到以下警告:

[-1.18840462+1.18840462j -0.10707968+0.10707968j -0.09787584+0.09787584j
 -0.05992208+0.05992208j  0.10880864+0.j          0.1484953 +0.j
  0.45161317+0.j          0.78783041+0.j          0.79189574+0.j
  0.93656538+0.j        ]

我尝试了/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) 中提到的解决方法,但这不起作用。

如何消除此警告?

2 个答案:

答案 0 :(得分:1)

对于 grequests ,您需要在其他模块尝试导入/加载gevent和ssl之前添加以下代码:

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

答案 1 :(得分:0)

您是否同时导入请求和grequest?也可能会导致问题。