1import time
2
3# timeout variable can be omitted, if you use specific value in the while condition
4timeout = 300 # [seconds]
5
6timeout_start = time.time()
7
8while time.time() < timeout_start + timeout:
9 test = 0
10 if test == 5:
11 break
12 test -= 1