As my question Title says, I need to kill a raw_input function if line stays blank for 2 seconds. How can I do that?
Asked
Active
Viewed 72 times
0
-
Sounds like you might need multithreading for this. https://stackoverflow.com/questions/2846653/how-to-use-threading-in-python – J0hn Jul 21 '17 at 16:01
-
1If you're not concerned about portability, [`signal.alarm`](https://docs.python.org/2/library/signal.html#signal.alarm) is one potential choice – anthony sottile Jul 21 '17 at 16:05
-
Anthony's solution could also work very well. Just be aware that even if you are typing, once the timer is up it will kill the raw_input function regardless for both solutions. – J0hn Jul 21 '17 at 16:06
-
If I type and it got killed after 2s can I get that input somehow? – Mihailo Jovanovic Jul 21 '17 at 16:52
-
this saves the partial input before the timeout https://stackoverflow.com/a/1336751/1248974 – chickity china chinese chicken Jul 21 '17 at 18:47