Question:
input()
pauses code execution while waiting for user input. Is there a way to skip this line if input()
hasn't received any input within X seconds?
Answer:
import multiprocessing.pool
def input_timeout(text: str, timeout: int):
return multiprocessing.pool.ThreadPool().apply_async(input, [text]).get(timeout)