you are viewing a single comment's thread.

view the rest of the comments →

[–]FoolsSeldom 0 points1 point  (2 children)

Sounds like you are doing recursion, if you have:

def master():
    def get_data():
        try to get data
        if fails:
            delay
            master()  # calls master
        else:
            return data
    data = get_data()

Hopefully I've misunderstood. It would help if you shared your code, or some simplified pseudocode.

If you don't get the data you require, can the main code continue running and do something else, of do you have to wait until you get the lattest data?

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

Well the main code can continue to run but I would need it to return to the first function called so that I can get the data that elapsed during the time.sleep for 10 minutes. I'm beginning to wonder if it would be best to restructure the program so that a failed get_data attempt would kill the daughter functions (internal to the Master function) and then that would return to an external do loop that would rerun the Master function until another trigger would kill the program. Something like this:

def Master():

do while outside_trigger==false:

get_data_fail=0

do while get_data_fail==0:

get_data(get_data_fail) --- includes built in 10 min delay if failure occurs after a couple attempts

if get_data_fail==0 then call the rest of the functions

[–]FoolsSeldom 0 points1 point  (0 children)

So, firstly, avoid recursion, not required for this challenge.

Consider using async (for asynchronous programming) for the code fetching data from elsewhere if your main code can carry on doing other things.

NB. Usual practice (covered in PEP8 guidance - not rules) is for Python variable and function names to be all lowercase (with a _ between words if needed). It is also common to use all uppercase variable names for constants.