question

Upvotes
Accepted
1 0 1 3

ReadTimeouts when Running In .py file and not in Jupyter Notebook

Hi everyone,

When I run the following requests in the syntax that you see below , in a Jupyter Notebook, the requests do not timeout, however, if this is run from a Python file, I see that it is more prone to ReadTimeout errors. Is there a way that I can go about fixing this error, and know why this is occurring?

tasks = asyncio.gather(
    fundamental_and_reference.Definition(universe=['VOD.L'],fields=['TR.F.IncAvailToComShr.date', 'TR.F.IncAvailToComShr'],parameters={"SDate": "2018-01-01", "EDate": "2023-12-31", "Frq": "CY"}).get_data_async(closure='Vodafone'),
    fundamental_and_reference.Definition(universe=['AAPL.O'],fields=['TR.F.IncAvailToComShr.date', 'TR.F.IncAvailToComShr'],parameters={"SDate": "2018-01-01", "EDate": "2023-12-31", "Frq": "CY"}).get_data_async(closure='Apple'),
    fundamental_and_reference.Definition(universe=['MSFT.O'],fields=['TR.F.IncAvailToComShr.date', 'TR.F.IncAvailToComShr'],parameters={"SDate": "2018-01-01", "EDate": "2023-12-31", "Frq": "CY"}).get_data_async(closure='Microsoft')
)


I have set the timeout length to 120 seconds.

Thanks!

python#technologyrdp-apifundamentalsjupyter-notebookreference-data
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvote
Accepted
87k 294 53 79

@vishal.nanwani

Thank you for reaching out to us.

Did you get this error: httpx.ReadTimeout?

You can increase the timeout in the configuration file. For example:

{
   ...
    "http": {
        "request-timeout": 300
  },

Otherwise, set it in the Python code.

config = ld.get_config()
config.set_param("http.request-timeout", 300)

ld.open_session()

We can't control how long the server uses to process those requests. The solution is increasing the http.request-timeout value.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.