Python
0
Вклад в тег
class TimeoutException(Exception):
pass
def timeout_handler(signum, frame):
raise TimeoutException
signal.signal(signal.SIGALRM, timeout_handler)
for link in result:
signal.alarm(10)
try:
( Выполнение вашей функции)
except TimeoutException:
continue # continue the for loop if function A takes more than n second
else:
signal.alarm(0)