gpt4 book ai didi

python - "RecursionError: maximum recursion depth exceeded"来自 ssl.py : `super(SSLContext, SSLContext).options.__set__(self, value)`

转载 作者:行者123 更新时间:2023-12-02 14:45:52 61 4
gpt4 key购买 nike

我在以下远程服务器设置上使用 Python 3.6.5:

Server: Windows 10

Python: 3.6.5

Requests: 2.18.4

Pentaho: 8.0

当我在服务器命令提示符中针对 URL 运行 request.get 时,它会按预期获取 JSON:

>>> import requests
>>> response = requests.get(url, headers=headers)
>>> json = response.json()
>>> print(json)
{'d': {'results': [{'_ ...

但是,当我在 CPython 中运行相同的脚本时对于 Pentaho 8.0,我得到

RecursionError: maximum recursion depth exceeded

完整日志:

2018/04/13 15:02:17 - Get SP Doc List.0 - ERROR (version 8.0.0.0-28, build 8.0.0.0-28 from 2017-11-05 07.27.50 by buildguy) : Unexpected error
2018/04/13 15:02:17 - Get SP Doc List.0 - ERROR (version 8.0.0.0-28, build 8.0.0.0-28 from 2017-11-05 07.27.50 by buildguy) : org.pentaho.di.core.exception.KettleException:
2018/04/13 15:02:17 - Get SP Doc List.0 - Traceback (most recent call last):
File "C:\Users\ADMINI~1\AppData\Local\Temp\2\pyServer.py", line 299, in execute_script
exec (script, _global_env)
File "<string>", line 16, in <module>
File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Program Files\Python36\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Program Files\Python36\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Program Files\Python36\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Program Files\Python36\lib\site-packages\urllib3\connection.py", line 314, in connect
cert_reqs=resolve_cert_reqs(self.cert_reqs),
File "C:\Program Files\Python36\lib\site-packages\urllib3\util\ssl_.py", line 269, in create_urllib3_context
context.options |= options
File "C:\Program Files\Python36\lib\ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "C:\Program Files\Python36\lib\ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "C:\Program Files\Python36\lib\ssl.py", line 465, in options
super(SSLContext, SSLContext).options.__set__(self, value)
[Previous line repeated 322 more times]
RecursionError: maximum recursion depth exceeded

脚本:

import requests
import json


# By Filename
url = "https://myco.sharepoint.com/teams/dg/l/_api/web/lists/GetByTitle('eRetail%20Data%20Sources')/items?..."

authtoken = "Bearer eyJ..."

headers = {
"Content-Type": "application/json;odata=verbose",
"Accept": "application/json;odata=verbose",
"Authorization": authtoken
}

response = requests.get(url, headers=headers)

json = response.json()
print('===========================')
print(json)

最佳答案

如果安装了 gevent,则需要对 python socket 进行猴子修补才能进行协作(请参阅 documentationthis github issue)。

因此,gevent.monkey.patch_all() 要么丢失,要么调用得不够早。

# at the beginning of the script
import gevent.monkey
gevent.monkey.patch_all()

# all the other stuff below, like for example
import requests

关于python - "RecursionError: maximum recursion depth exceeded"来自 ssl.py : `super(SSLContext, SSLContext).options.__set__(self, value)` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49820173/

61 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com