简体   繁体   English

读取超时。 (读取超时=无)通过 simple_salesforce API 在 Python 中插入记录时

[英]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 的方法:

And a third and fourth:第三和第四:

  • The Salesforce object has a "restful" method that can make arbitrary API calls. Salesforce object 有一个“restful”方法,可以进行任意 API 调用。 In other words, you can roll your own using, for instance, the Bulk API 2.0换句话说,您可以使用例如Bulk API 2.0自行滚动
  • Once you are this far in, however, perhaps you want to make the API calls directly using the Requests library?但是,一旦您深入到这里,也许您想直接使用Requests库进行 API 调用? It is a great library to work with, and you don't run into simple_salesforce's limitations.这是一个很棒的库,你不会遇到 simple_salesforce 的限制。

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.

相关问题 HTTPConnectionPool(host=&#39;xxxx&#39;, port=y):读取超时。 (读取超时=无)在 nginx 服务器上? - HTTPConnectionPool(host='x.x.x.x', port=y): Read timed out. (read timeout=None) on nginx server? Newspaper3k API 文章下载()失败,HTTPSConnectionPool 端口=443 读取超时。 URL 上的(读取超时 = 7) - Newspaper3k API Article download() failed with HTTPSConnectionPool port=443 Read timed out. (read timeout=7) on URL ElasticSearch 超时错误:ReadTimeoutError(HTTPConnectionPool(host=&#39;localhost&#39;, port=9200): 读取超时。(读取超时=60)) - ElasticSearch Timeout Error: ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=60)) ReadTimeout: HTTPSConnectionPool(host=&#39;&#39;, port=443): 读取超时。 (读取超时=10) - ReadTimeout: HTTPSConnectionPool(host='', port=443): Read timed out. (read timeout=10) 由-ReadTimeoutError(HTTPConnectionPool(host = u&#39;localhost&#39;,port = 9200)引起的ConnectionTimeout:读取超时。(读取超时= 10) - ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host=u'localhost', port=9200): Read timed out. (read timeout=10)) python simple_salesforce查询全部 - python simple_salesforce query all 读取超时。 向 node.js API 发送 POST 请求时出错 - Read timed out. error while sending a POST request to a node.js API python simple_salesforce代理用法 - python simple_salesforce proxy usage ArangoDB 读取超时(读取超时=60) - ArangoDB Read timed out (read timeout=60) 在 python 中使用 simple_salesforce package 更新 SalesForce 中的现有报表 - Update an existing report in SalesForce using simple_salesforce package in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM