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!

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @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.