A-A+

python gevent异常:MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors

2019年04月19日 异常 python gevent异常:MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors已关闭评论 阅读 272 次

异常:

python gevent魔法补丁出现错误提示:MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError

原因:

import包名顺序导入错误,使用gevent,务必将import gevent,from gevent import monkey,monkey.patch_all()三行语句放在其他所有的import语句之前

例子:

don16@don16-VirtualBox:~$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> import gevent
>>> from gevent import monkey
>>> monkey.patch_all()
__main__:1: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016
True
>>> quit()
don16@don16-VirtualBox:~$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent
>>> from gevent import monkey
>>> monkey.patch_all()
True
>>> import requests
>>>

 

标签:

评论已关闭!

Copyright © C/C++程序员之家 保留所有权利.   Theme  Ality 浙ICP备15011757号-3

用户登录