本文主要是介绍python3 requests https 请求 报 SSLContext 相关递归错误,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、错误信息:
2019-11-19 15:14:40 : Provider before requests .post
2019-11-19 15:14:41 : error infoTraceback (most recent call last):File "/root/operation/spider/web/lh_spider_config/utils/run_provider/service/provider.py", line 782, in parse_page_type_apiproxies=proxies, data=params, timeout=8)File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/api.py", line 116, in postreturn request('post', url, data=data, json=json, **kwargs)File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/api.py", line 60, in requestreturn session.request(method=method, url=url, **kwargs)File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/sessions.py", line 533, in requestresp = self.send(prep, **send_kwargs)File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/sessions.py", line 646, in sendr = adapter.send(request, **kwargs)File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/adapters.py", line 449, in sendtimeout=timeoutFile "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopenchunked=chunked,File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_requestself._validate_conn(conn)File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in _validate_connconn.connect()File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connection.py", line 370, in connectcert_reqs=resolve_cert_reqs(self.cert_reqs),File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 273, in create_urllib3_contextcontext.options |= optionsFile "/usr/local/python36/lib/python3.6/ssl.py", line 465, in optionssuper(SSLContext, SSLContext).options.__set__(self, value)File "/usr/local/python36/lib/python3.6/ssl.py", line 465, in optionssuper(SSLContext, SSLContext).options.__set__(self, value)File "/usr/local/python36/lib/python3.6/ssl.py", line 465, in optionssuper(SSLContext, SSLContext).options.__set__(self, value)[Previous line repeated 3308 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object
二、参考:
https://www.jianshu.com/p/7bac63928ba7
https://luxrck.github.io/p/gevent-ssl-infinity-recursion-error/
https://blog.dreamfever.me/2019/03/24/you-gevent-ssl-yin-fa-de-xy-problem/
https://stackoverflow.com/questions/13194064/using-celery-on-processes-and-gevent-in-tasks-at-the-same-time
三、解决:
- patch要放在requests前面
import gevent.monkey
gevent.monkey.patch_all()
import requests
2.如果放在celery里面跑,celery 启动时候要加上 -P gevent
这篇关于python3 requests https 请求 报 SSLContext 相关递归错误的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!