def signal_handler(_, _1):
raise TimeoutError("Timed out!")
signal.signal(signal.SIGALRM, signal_handler)
signal.alarm(time_limit) // Ten seconds
try:
while True:
p = multiprocessing.Process(target=run_searcher_once, args=(x_train, y_train, x_test, y_test, self.path))
After Change
p.start()
// Kill the process if necessary.
while time.time() - start_time <= time_limit:
if p.is_alive():
time.sleep(1)
else:
break
else:
// If break above the code in this else won"t run
p.terminate()
p.join()