【递归报错】requests 递归深度报错

背景:最近遇到一个诡异的问题,requests竟然递归报错,然后重启Django后正常运行一段时间,

maximum recursion depth exceeded while calling a Python object

 百思不得其解,找了很多办法,包括打猴子补丁。

from gevent import monkey
monkey.patch_all(ssl = False)

打了补丁还是不行,还是报错,加了 异常日志追踪

print(traceback.format_exc())

更详细的报错日志

stdoutIO函数报错
代码运行错误:
 maximum recursion depth exceeded while calling a Python object
Traceback (most recent call last):
  File "/home/myTestPlatform/myTestPlatform_django/apps/vadmin/scriptfactory/common_method.py", line 55, in stdoutIO
    yield stdout
  File "/home/myTestPlatform/myTestPlatform_django/apps/vadmin/scriptfactory/common_method.py", line 70, in get_output_after
    exec(code, globals())
  File "<string>", line 3, in <module>
  File "/usr/local/lib/python3.8/dist-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/dist-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 996, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 334, in connect
    self.ssl_context = create_urllib3_context(
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 273, in create_urllib3_context
    context.options |= options
  File "/usr/lib/python3.8/ssl.py", line 602, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  File "/usr/lib/python3.8/ssl.py", line 602, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  File "/usr/lib/python3.8/ssl.py", line 602, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  [Previous line repeated 461 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

后来在bing搜到一个解决版本,升级了eventlet库,从30.2版本升级到33.0

pip3 install eventlet

 就解决了,后续再观察下,莫名其妙运行1 2天后报错,先记录下

原文链接:Python SSL recursion error -> super(SSLContext, SSLContext).options.__set__(self, value) requests: RecursionError: maximum recursion depth exceeded · Issue #618 · eventlet/eventlet · GitHub

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值