Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to end an infinite loop in specific time python

import time

# timeout variable can be omitted, if you use specific value in the while condition
timeout = 300   # [seconds]

timeout_start = time.time()

while time.time() < timeout_start + timeout:
    test = 0
    if test == 5:
        break
    test -= 1
Comment

PREVIOUS NEXT
Code Example
Python :: RuntimeError: dictionary changed size during iteration 
Python :: Python message popup 
Python :: python loop shorthand 
Python :: to_cvs python 
Python :: append data to column in pan 
Python :: basic flask app 
Python :: python convert list of lists to array 
Python :: python remove spaces from string 
Python :: python how to draw a circle 
Python :: Python Add a string in a certain position 
Python :: python *args 
Python :: best fit line python log log scale 
Python :: discord.py get id of sent message 
Python :: python remove one element from numpy array 
Python :: savefig matplotlib python 
Python :: deep clone 2d list python 
Python :: Got AttributeError when attempting to get a value for field `name` on serializer 
Python :: Python NumPy ndarray flatten Function Example 
Python :: jupyter notebook GET 500 
Python :: discord.py message user 
Python :: enumerate items python 
Python :: read image and resize 
Python :: How do you create an matrix of random integers in Numpy? 
Python :: numpy multiply element wise 
Python :: raw input py 
Python :: Add PostgreSQL Settings in Django 
Python :: pass arguments with apply 
Python :: tqdm description 
Python :: xlabel font type matplotlib 
Python :: pygame check collision 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =