首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GRequests猴贴片警告

GRequests猴贴片警告
EN

Stack Overflow用户
提问于 2019-05-26 00:31:09
回答 2查看 9.9K关注 0票数 9

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

代码语言:javascript
复制
/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问题上提到的解决方法,但这不起作用。

如何消除这个警告?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-07-25 08:13:38

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

代码语言:javascript
复制
from gevent import monkey as curious_george
curious_george.patch_all(thread=False, select=False)
票数 14
EN

Stack Overflow用户

发布于 2022-08-12 10:50:01

请参阅grequests:https://github.com/spyoungtech/grequests

好:

代码语言:javascript
复制
import grequests 

import requests

坏:

代码语言:javascript
复制
import requests 

import grequests
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56309763

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档