gagebenne/pydexcom

Timeouts in v0.3.0

Closed this issue · 4 comments

bogosj commented

I upgraded to v0.3.0 yesterday, and ever since I've been experiencing this error:

Traceback (most recent call last):
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/alert.py", line 47, in <module>
    bg = dexcom.get_current_glucose_reading()
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/pydexcom/__init__.py", line 301, in get_current_glucose_reading
    glucose_readings = self.get_glucose_readings(minutes=10, max_count=1)
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/pydexcom/__init__.py", line 285, in get_glucose_readings
    json_glucose_readings = self._get_glucose_readings(minutes, max_count)
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/pydexcom/__init__.py", line 258, in _get_glucose_readings
    return self._post(
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/pydexcom/__init__.py", line [144](https://github.com/bogosj/dexcom-trend-alert/actions/runs/6123133473/job/16620386444#step:4:145), in _post
    response = self.__session.post(
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/home/runner/work/dexcom-trend-alert/dexcom-trend-alert/env/lib/python3.10/site-packages/requests/adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='share2.dexcom.com', port=443): Read timed out. (read timeout=10)

I'll handle this in my calling code with retries, but perhaps the timeout length could be configurable?

Thanks for opening the issue, I'll look into a resolution today.

bogosj commented

FWIW I wrapped my calls up with @backoff. I suspect that will help.

bogosj/dexcom-trend-alert@450248d

Okay, you wanna give 0.3.1 a shot? I just removed the timeout that I added in 0.3.0. I'll look into a more reasonable timeout if necessary in a later release, but that should get things back to working.

bogosj commented

Thanks, I upgraded to 0.3.1 but I'm going to leave my backoff code in place as a backup.