一、错误信息:
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_api
proxies=proxies, data=params, timeout=8)
File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/api.py", line 116, in post
return 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 request
return 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 request
resp = self.send(prep, **send_kwargs)
File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
conn.connect()
File "/root/operation/spider/web/web_env/lib/python3.6/site-packages/urllib3/connection.py", line 370, in connect
cert_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_context
context.options |= options
File "/usr/local/python36/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/local/python36/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/local/python36/lib/python3.6/ssl.py", line 465, in options
super(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
三、解决:
import gevent.monkey
gevent.monkey.patch_all()
import requests
2.如果放在celery里面跑,celery 启动时候要加上 -P gevent