[英]Read timed out. (read timeout=None) when inserting records through simple_salesforce API in Python
I am getting a "ReadTimeout: HTTPSConnectionPool(host=', port=443): Read timed out. (read timeout=None)" while inserting records using bulk api of simple_salesforce library of python.在使用 python 的 simple_salesforce 库的批量 api 插入记录时,我收到“ReadTimeout: HTTPSConnectionPool(host=', port=443): Read timed out. (read timeout=None)”。 I have not set any timeout limit and I am trying to insert around 3M records.我没有设置任何超时限制,我正在尝试插入大约 3M 条记录。 I also tried inserting in small chunks, but it has the same issue.我也尝试插入小块,但它有同样的问题。 Please let me know if any one of you have faced any such issues.如果你们中的任何人遇到过任何此类问题,请告诉我。
My Code:我的代码:
from simple_salesforce import Salesforce, SalesforceLogin
sf = Salesforce(username= ''
,password= ''
,security_token= '')
bulk_data = []
for row in <data_to_be_inserted>.itertuples():
d = row._asdict()
del d['Index']
bulk_data.append(d)
sf.bulk.<Custom_Object_Name>.insert(bulk_data)
Yes, try increasing the timeout on the Requests session.是的,尝试增加请求session 的超时时间。
The simple_salesforce package uses Requests under the hood. simple_salesforce package 在后台使用请求。 Unfortunately, simple_salesforce does not appear to expose the timeout
parameter.不幸的是,simple_salesforce 似乎没有公开timeout
参数。
Thankfully, it does allow you to customize the session and pass that into the Salesforce()
constructor.值得庆幸的是,它确实允许您自定义 session 并将其传递给Salesforce()
构造函数。
Here are two ways I found online to hack the session:以下是我在网上找到的两种破解 session 的方法:
functools.partial
这似乎更容易:使用functools.partial
And a third and fourth:第三和第四:
I would love to be wrong about timeout
.我很想弄错timeout
。 If anyone knows a way to set it from simple_salesforce, I am all ears.如果有人知道从 simple_salesforce 设置它的方法,我会全神贯注。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.