I would like to monitor the progress of a given Python function (for those that know it, GridSearchCV from machine learning package Scikit Learn) during its execution. To do so, given the function has a parameter verbose, I can set the verbosity to be 1 or 10, whatever. However, I would also like to have some kind of time monitoring. The idea I had was to print on the console a timer each time something is printed in the console (in this case, printings would come from the activation of the verbosity of GridSearchCV), let's call this the printing function. 
My questions are the following:
- Is there a way in Python to execute a program when something is printed in the console?
- A difficulty I see here is that, when I execute all these instructions (function GridSearchCV, theprinting function), I am afraid what will happen is thatGridSearchCVwill be executed entirely, and then all the timers will be printed at the end. Is there a way to avoid this?
 
    