【错误集】 MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors

博客内容涉及Python中遇到的MonkeyPatchWarning错误,该错误警告在ssl模块已经被导入后进行monkey-patching可能会导致错误,尤其是在Python 3.6上可能引发RecursionError。在Python 3.7上,它可能悄无声息地导致行为不正确。解决方法是提前进行monkey-patching。错误显示了直接导入ssl的模块。修改后的代码消除了这个警告,关键在于调整requests和patch_all的导入顺序。
摘要由CSDN通过智能技术生成

原代码

import gevent

from gevent.queue import Queue,Empty
import time
import requests
#把下面有可能有IO操作的单独坐上标记
from gevent import monkey
monkey.patch_all()#将IO转为异步执行的函数

错误

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.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值