print('Thread finished')
thread = threading.Thread(target=target)
thread.start()
thread.join(timeout)
if thread.is_alive():
    print('Terminating process')
self.process.terminate()
thread.join()
print(self.process.returncode)
command = Command("echo 'Process started'; sleep 2; echo 'Process finished'")
command.run(timeout=3)
command.run(timeout=1)
Использование модуля «подпроцесс» с тайм-аутом