I'm calling several functions from one main function mainFunc (which is exposed as Restful service using flask module). Execution may take few minutes to an hour to complete and requirement is to display progress (output of functions being called) every 30 seconds. As Rest API calls are made from another program to mainFunc() so it should return the output (i.e current status) at each call.
I tried yield and StringIO as per How to capture stdout output from a Python function call? but could not make it work, stdout is returned only on completion of all tasks and not in between. Please suggest if this can be done.
mainFunc():
runs_for_5_mins()
runs_for_30_mins()
...
return output