Forums

Internet connection issues in scheduled tasks?

I run some public python module that downloads data from the web (I can give more details, but I think this shouldn't matter). On my local machine this module generates weird and uncatchable errors, if the wifi is unstable or poor. However, in very rare cases I get the same types of errors within scheduled tasks at pythonanywhere. To my understanding, scheduled tasks cannnot loose internet connection. Could you please tell me whether there might be reasons why this can happen at pythonanywhere? Or do you have any idea what could cause similar error than internet connection issues at local machine? Thanks

There are many "places" between machine running your task and the machine serving the service you try to access where network issues may happen. What is the specific error you get? Email us at support@pythonanywhere.com if you don't want to share details on a public forums.

I'm using a module called yahoo finance (yfinance) that downloads financial market data. I call for example df=yf.download('^GSPC', '1d', '30y'). In 99% of all cases, I get a fine dataframe with market prices of S&P500 of the last 30 years. However, sometimes I get the error "no data found for symbol GSPC, symbol may be delisted". But it isn't of course, as it works fine almost always. I have the feeling that this happens especially if there have been for example a time.sleep(5000) before I execute the download function. But this might be random.

The only fix I could imagine, would be to add a try except that checks whether the dataframe is empty and retry if yes. However my code also tries to download symbols that actually may be delisted (for example Facebook which is now called META). Therefore I cannot distinguish between connection errors and actual delisted symbols..

That is a yahoo issue - if they're returning different responses for the same request, there's nothing that we can do about it. Perhaps you can keep a list of symbols that you know are delisted and retry on the ones that are not in the list.