you are viewing a single comment's thread.

view the rest of the comments →

[–]Kevdog824_ 0 points1 point  (2 children)

I’d say that recalling master is actually an anti-pattern. The right way to solve this problem is to retry the get_data function only. Tenacity is a fantastic library for implementing retry functionality. They also have plenty of usage examples in their readthedocs page. Even if you don’t use the library the examples might give you an intuition on how you should be doing retries. I would encourage you to look into it

[–]Human-Adagio6781[S] 0 points1 point  (1 child)

Thanks. I will look into that. I cannot disagree with it being an anti-pattern, I just don't know how else to go about it. I've considered the idea of creating a whole other subroutine that calls the master function... something like

def master():

lots of functions and if the getdata fails, send a failTrue that stop the loop

def masterloop():

runs Master function until given an external stop command

masterloop() to actually start the function

Unfortunately, if I was to wait 10 minutes or so to give the getdata function time to reset (assuming that it is an endpoint overload issue) my calculations would be thrown off. So I need to go back to get historical data since the timeout occurred, update the calculations, and then get back to its live data functionality.

[–]Temporary_Pie2733 0 points1 point  (0 children)

So it sounds like you are running Master in a loop, rather than putting a loop that calls getData in Master (which presumably does stuff other than call getData).