This should do the trick
from time import sleep
. . .
while not process_exists('PROCESS_NAME'):
sleep(0.05)
But Kickin_Wing raises a good point that you should include a timeout period to make this more resilient. One way you could do that is like this (adjusting the timeoutCtr check in the if statement to your needs)
from time import sleep
. . .
timeoutCtr = 0
while not process_exists('PROCESS_NAME'):
timeoutCtr = timeoutCtr + 1
if timeoutCtr > 100:
print("error: PROCESS_NAME did not appear within 5 seconds")
exit(1)
sleep(0.05)
This way, your program will stop and let you know what's going on if the process name takes too long to appear instead of simply trying and failing to do what you were planning to do after process_exists() and giving a more confusing runtime error