PI-Web-API-Client-Python icon indicating copy to clipboard operation
PI-Web-API-Client-Python copied to clipboard

make _request_timeout args work as expected; add default timeout

Open mike-eh2 opened this issue 9 months ago • 1 comments

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:

  1. Fixes the implementation of the _request_timeout arg so that it works as intended
  2. 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.

mike-eh2 avatar Apr 16 '25 17:04 mike-eh2