dr-leo / pandaSDMX

Python interface to SDMX
Apache License 2.0
128 stars 60 forks source link

passing timeout argument in datastructure request #216

Closed beto-Sibileau closed 2 years ago

beto-Sibileau commented 3 years ago

Dear @dr-leo, while requesting data/metadata for EUROSTAT, long response times are reported. Thus, I'm interested in controlling the timeout argument for requests, how could I do that? Eg: for the metadata requested below:

import pandasdmx as pdsdmx
# exploring ESTAT
Estat = pdsdmx.Request('ESTAT', backend='memory')
# unmet health
dataflow_name = 'hlth_silc_08'
# dsd name
dsd_name = f"DSD_{dataflow_name}"
Dsd_estat = Estat.datastructure(dsd_name, timeout=5)

this is the error observed: TypeError: _request_from_args() got an unexpected keyword argument 'timeout'

dr-leo commented 3 years ago

Pass the time out argument when instantiating the request object, not when calling methods on it.

Am 05.07.2021 um 13:03 schrieb beto Sibileau @.***>:

 Dear @dr-leo, while requesting data/metadata for EUROSTAT, long response times are reported. Thus, I'm interested in controlling the timeout argument for requests, how could I do that? Eg: for the metadata requested below:

import pandasdmx as pdsdmx

exploring ESTAT

Estat = pdsdmx.Request('ESTAT', backend='memory')

unmet health

dataflow_name = 'hlth_silc_08'

dsd name

dsdname = f"DSD{dataflow_name}" Dsd_estat = Estat.datastructure(dsd_name, timeout=5) this is the error observed: TypeError: _request_from_args() got an unexpected keyword argument 'timeout'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

beto-Sibileau commented 3 years ago

Thanks @dr-leo that makes sense and was my first try indeed. However, check it for yourself that this is not passed automatically for all queries as described in the documentation, eg:

import pandasdmx as pdsdmx
Estat = pdsdmx.Request('ESTAT', backend='memory', timeout=0.000000001)
dataflow_name = 'hlth_silc_08'
# timeout in the query below is not applied
Dsd_estat = Estat.datastructure(f"DSD_{dataflow_name}")

Pass the time out argument when instantiating the request object, not when calling methods on it. Am 05.07.2021 um 13:03 schrieb beto Sibileau @.***>:  Dear @dr-leo, while requesting data/metadata for EUROSTAT, long response times are reported. Thus, I'm interested in controlling the timeout argument for requests, how could I do that? Eg: for the metadata requested below: import pandasdmx as pdsdmx # exploring ESTAT Estat = pdsdmx.Request('ESTAT', backend='memory') # unmet health dataflow_name = 'hlth_silc_08' # dsd name dsdname = f"DSD{dataflow_name}" Dsd_estat = Estat.datastructure(dsd_name, timeout=5) this is the error observed: TypeError: _request_from_args() got an unexpected keyword argument 'timeout' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

dr-leo commented 3 years ago

OK this looks like a bug I see two possible workarounds after instantiating the request object, use its time out property to set the desired value. Second pass a request session object upon instantiation with the desired time out value.

Am 05.07.2021 um 14:10 schrieb beto Sibileau @.***>:

 Thanks @dr-leo that makes sense and was my first try indeed. However, check it for yourself that this is not passed automatically for all queries as described in the documentation, eg:

import pandasdmx as pdsdmx Estat = pdsdmx.Request('ESTAT', backend='memory', timeout=0.000000001) dataflow_name = 'hlth_silc_08'

timeout in the query below is not applied

Dsdestat = Estat.datastructure(f"DSD{dataflow_name}") Pass the time out argument when instantiating the request object, not when calling methods on it. … Am 05.07.2021 um 13:03 schrieb beto Sibileau @.***>:  Dear @dr-leo, while requesting data/metadata for EUROSTAT, long response times are reported. Thus, I'm interested in controlling the timeout argument for requests, how could I do that? Eg: for the metadata requested below: import pandasdmx as pdsdmx # exploring ESTAT Estat = pdsdmx.Request('ESTAT', backend='memory') # unmet health dataflow_name = 'hlth_silc_08' # dsd name dsdname = f"DSD{dataflow_name}" Dsd_estat = Estat.datastructure(dsd_name, timeout=5) this is the error observed: TypeError: _request_from_args() got an unexpected keyword argument 'timeout' — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

dr-leo commented 2 years ago

timeout should now - v1.8.0 - be passed to any request. Please reopen if needed.