3

Is there a way to give the user a raw_input, but give a null response ("") if nothing is typed within x amount of time? I'd like to give the user 10 seconds to enter options when the script starts, but if time expires (or they press enter), simply continue the script. If you know AppleScript, I'd like display dialog "Enter options" giving up after 10 in python

tkbx
  • 15,602
  • 32
  • 87
  • 122
  • 2
    You _could_ collect the user input in a separate process, and then use the `terminate()` method on that process after a specific amount of time. – Joel Cornett Jul 07 '12 at 00:52

1 Answers1

2

If you are in unix-land, you can use python's signal library and use an alarm. Otherwise, I think raw_input is totally thread-blocking.

See this answer for implementation help.

Community
  • 1
  • 1
mayhewr
  • 4,003
  • 1
  • 18
  • 15