One - One Code All

Blog Content

python中gevent monkey_patch 出现Monkey-patching may lead to errors解决

Python   2019-03-10 09:07:47

  在使用多进程加协程时,patch_all()后出现警告信息:MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError。有时会导致不能正常使用requests或者其他包,其实只要调整import的顺序即可,把import gevent,from gevent import monkey,monkey.patch_all()三行语句放在其他所有的import语句之前,可以避免出现警告或者报错信息,导致程序不能正常运行。

import gevent
from gevent import monkey
monkey.patch_all()



上一篇:postgresql导入导出
下一篇:Linux nohup实现后台运行程序及查看(nohup与&)

The minute you think of giving up, think of the reason why you held on so long.