I just recently started using the Simple_Saleforce package for python https://pypi.python.org/pypi/simple-salesforce
I am wondering how long does the connection last once you have logged in? Is there a manual way to close() the connection? I have looked through the documentation and source code, but perhaps I missed this little detail.
As context, I am building a celery task to poll salesforce every few minutes and was wondering do I need to reopen a connection (i.e. login) every time I poll, or if the global login will suffice (for how long)?
Thanks!
From the SalesFOrce REST API that is used by simple-salesforce library:
Access tokens have a limited lifetime specified by the session timeout in Salesforce. If an application uses an expired access token, a “Session expired or invalid” error is returned. If the application is using the Web server or user-agent OAuth authentication flows, a refresh token may be provided during authorization that can be used to get a new access token.
So yes, there is a timeout for your session, and from the documentation you can set it up on your SalesForce:
The session timeout for an access token can be configured in Salesforce from Setup by clicking Security Controls | Session Settings.
So yes you have to request a new session ID once your session timed out. And if you want to close the connection manually you can destroy the session by setting its age: session.setMaxAge(-1).
Link to the full documentation
Hope this help, Cheers!