PI-Web-API-Client-Python
PI-Web-API-Client-Python copied to clipboard
make _request_timeout args work as expected; add default timeout
My team was intermittently receiving alerts about the following error coming from requests through the PI web API client:
HTTPSConnectionPool(host='[redacted], port=443): Max retries exceeded with url:
/piwebapi/attributes?path=[redacted] (Caused by ConnectTimeoutError(
urllib3.connection.HTTPSConnection object at 0x7fbf482d9a20,
'Connection to [redacted] timed out. (connect timeout=None)'))
I saw that the client's API methods do accept _request_timeout arguments, but those arguments are not actually passed through to the request, so they don't do anything. This PR does two things:
- Fixes the implementation of the
_request_timeoutarg so that it works as intended - Adds a default timeout. With no default in place, the timeout depends on the host system, which can cause issues when the application moves between platforms, as happened in my case.
We have been running this branch in production and our timeout issues are resolved.