Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Timeouts #15

Closed
davidhuser opened this issue Feb 28, 2020 · 1 comment
Closed

Timeouts #15

davidhuser opened this issue Feb 28, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@davidhuser
Copy link
Owner

davidhuser commented Feb 28, 2020

implement optional parameter for https://requests.readthedocs.io/en/master/user/quickstart/#timeouts

You can tell Requests to stop waiting for a response after a given number of seconds with the timeout parameter. Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely.

at https://github.com/davidhuser/dhis2.py/blob/master/dhis2/api.py#L202

@davidhuser davidhuser added the enhancement New feature or request label Feb 28, 2020
@davidhuser davidhuser changed the title Implement timeouts Timeouts Feb 28, 2020
@davidhuser
Copy link
Owner Author

davidhuser commented Aug 12, 2021

Implemented in v2.2.0 with a default of 5 seconds, and in v2.2.1 with a no default value again.

Nearly all production code should use this parameter in nearly all requests.

If you face errors such as:

requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='play.dhis2.org/demo', port=443): Read timed out. (read timeout=5)

You can improve your code by setting your own appropriate timeout values by overwriting the timeout parameter in seconds:

from dhis2 import Api

api = Api('play.dhis2.org/demo', 'admin', 'district')
r = api.get('endPoint', timeout=60) # <-- see here
data = r.json()

@davidhuser davidhuser pinned this issue Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant