What is the most efficient way to wait for a condition to be true before executing certain code? For example I want to execute code only if a file is modified. My code is within a 'white True:' loop. I'm not sure if this is the best thing to do or if this is common practice because the 'while True:' loop is constantly looping and using up the cpu. I can put a pause statement in there but I want to know what's the defacto way to do this? The script needs to be continuously running while waiting for the condition to be true.
while True:
modTime = os.path.getmtime('C:\\example1.xlsx')
if(modTime > curTime):
#execute code
#execute code
#execute code
curTime = modTime