0

I want to get input from console "forcefully" upon a timeout. Normally, input() returns user-input only after the user presses Enter, and sys.stdin.read() terminates only after it reaches EOF. I want to retain that behavior and add a little extra something to it. Let's call this desired input function sinput(). Upon elapsing 10 seconds of the call to sinput(), it would automatically make the user-input from stdin available to the program for processing even if the user hasn't pressed Enter by then. If the user hits return before 10 seconds, though, the script runs just fine: it collects the user-input and continues. How do I implement this?

HERO
  • 164
  • 2
  • 8

1 Answers1

-1

Please review Sci Prog solution. I tried and it does work. python expire input prompt after timeout

For adding timeer, simply import time package and add time.sleep(5) between start() and join() lines for example for 5.

enter image description here

Gedas Miksenas
  • 959
  • 7
  • 15