Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5485

Python • Re: Wait for app to open with Python

$
0
0
So @ame something like this?

Code:

import timeimport datetimeimport subprocesssuccess = Falsecurtime = date = datetime.datetime.now()t_end = time.time() + 20while time.time() < t_end:   try:      subprocess.run(['python', 'my-script.py'])      success = True   except:      time.sleep(1)   if success:      break

Statistics: Posted by Henrik Gill — Sun Jul 07, 2024 1:29 pm



Viewing all articles
Browse latest Browse all 5485

Trending Articles