Background timer while python code is running | Sololearn: Learn to code for FREE!

+1

Background timer while python code is running

hi guys, I made a bot using pyautogui. It's looped and it takes abt 25 sec per loop to complete. but sometimes something goes wrong and it's stuck on a task. So what i thought to do, was to check if the loop takes longer for lets say 35 sec, it shutdows the code and does something else. Some kind of failsafe i suppose. Is there anyway i can do this?

7/24/2021 12:21:52 PM

Jordi de Pelseneer

4 Answers

New Answer

+1

Jordi de Pelseneer The problem is that the maximum runtime of a Python code in SoloLearn is very less; it's 10 seconds I guess. Try using PyDroid. If you want, you may post the link to your code here.

+1

no no im not using sololearn

+1

Jordi de Pelseneer Okay. Please copy the code to SoloLearn and post the link to your code here.

0

Jordi de Pelseneer How about running a second cmd process to terminate the first one and start a second Python process if the time limit is reached? I'd like to know in which application you're planning to execute the code in.