aliyun / aliyun-odps-python-sdk

ODPS Python SDK and data analysis framework
http://pyodps.readthedocs.io
Apache License 2.0
434 stars 97 forks source link

DataFrame.persist fail in Python3.9 #228

Closed ianzhy closed 5 months ago

ianzhy commented 8 months ago

odps version==0.11.4.1。 在3.9下,DataFrame报ResponseNotReady, 在3.6-3.8下都是好的,看了下是因为urllib3在3.9改动较大的原因,改一下odps/lib/requests/adapters.py就行,放在这里供参考。 修改三处地方:(1)增加import urllib3; (2)533行获得low_conn以后添加_response_options; (3) 557行 urllib3直接返回HTTPResponse了,直接改为resp=r。

15a16
> import urllib3
533c534,541
< 
---
>                 low_conn._response_options = urllib3._base_connection._ResponseOptions(
>                     request_method=request.method,
>                     request_url=url,
>                     preload_content=True,
>                     decode_content=True,
>                     enforce_content_length=True,
>                 )
>                 
557,564c565,572
< 
<                     resp = HTTPResponse.from_httplib(
<                         r,
<                         pool=conn,
<                         connection=low_conn,
<                         preload_content=False,
<                         decode_content=False
<                     )
---
>                     resp = r
>                     # resp = HTTPResponse.from_httplib(
>                     #     r,
>                     #     pool=conn,
>                     #     connection=low_conn,
>                     #     preload_content=False,
>                     #     decode_content=False
>                     # )
bixiadaren commented 6 months ago

python 3.10 + pyodps 0.11.5 also had this problem. I solved the problem the way you did. But it seems that only the last two changes are needed.

Thank you very much.

wjsi commented 5 months ago

Fixed in PyODPS 0.11.6 by using public version of requests.