def cli():
    while True:
        cli = str(input(PROMPT))
if __name__ == '__main__':
    threading.Thread(target=cli).start()
threading.Timer(2, interrupt).start()
How to implement a python REPL that nicely handles asynchronous output?