Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to pass request timeouts to Salesforce http operations #148

Open
banjoh opened this issue Jan 28, 2017 · 7 comments · May be fixed by #631
Open

Ability to pass request timeouts to Salesforce http operations #148

banjoh opened this issue Jan 28, 2017 · 7 comments · May be fixed by #631

Comments

@banjoh
Copy link

banjoh commented Jan 28, 2017

In an automated environment, requests to Saleforce not timing out can cause really bad service interruptions. I've had cases where a service has "gone silent" for a few days. At the moment most of the API calls have no mechanism to pass in the timeout parameter to requests. I've had blocked requests when trying to login and when performing operations related to salesforce objects.

Generally we should be able to pass down parameters to requests. This issue is also similar to #81

@ddow
Copy link

ddow commented Jan 28, 2017

This request is full of win.

@ivanpricewaycom
Copy link

Hello, we are interested in this merge, is there a timeline / estimate for a release ?

cheers

@JackaDu
Copy link

JackaDu commented Jul 25, 2017

Me, too. The salesforce connection has been silent for 7 hours

@alexprice1
Copy link

+1

@pdr
Copy link

pdr commented May 17, 2019

In light of recent Salesforce issues, it seems like this is getting more and more critical.

@chingc
Copy link

chingc commented May 17, 2019

+1

@nmassman
Copy link
Contributor

So you can actually set a timeout for every call of a particular requests session by attaching your own HTTP adapter. This is the solution I've used in my own usage of simple_salesforce as well as for other modules that let you provide your own requests.Session() object.

class TimeoutAdapter(requests.adapters.HTTPAdapter):
    def send(self, *args, **kwargs):
        kwargs['timeout'] = 30
        return super().send(*args, **kwargs)

sfSession = requests.Session()
sfSession.mount("https://", TimeoutAdapter())
sfSession.mount("http://", TimeoutAdapter())

Then pass session=sfSession when you instantiate your Salesforce object.

There is actually a lot of powerful things you can do with overriding parts of the default HTTPAdaptor in requests.
https://requests.readthedocs.io/en/master/user/advanced/#transport-adapters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants