Background timer while python code is running | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

24th Jul 2021, 12:21 PM
Jordi
Jordi - avatar
4 Answers
+ 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.
24th Jul 2021, 12:25 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
no no im not using sololearn
24th Jul 2021, 12:27 PM
Jordi
Jordi - avatar
+ 1
Jordi de Pelseneer Okay. Please copy the code to SoloLearn and post the link to your code here.
24th Jul 2021, 12:29 PM
Calvin Thomas
Calvin Thomas - avatar
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.
24th Jul 2021, 2:52 PM
Calvin Thomas
Calvin Thomas - avatar