[Tutor] Requesting input, waiting a fixed time
'Gerrit Holl'
gerrit@nl.linux.org
Wed, 1 Mar 2000 20:56:45 +0100
<quote name="Hicks,David P.(NXI)" date="951914700" email="David.Hicks@cna.com">
> Thanks for the prompt response. My understanding is that raw input will ask
> for a response, but will not solve the problem of assuming a response after
> 3 minutes. That is, the program will continue waiting forever. Am I correct?
> Is there a way around this?
http://www.python.org/doc/current/lib/module-signal.html
alarm (time)
If time is non-zero, this function requests that a SIGALRM
signal be sent to the process in time seconds. Any previously
scheduled alarm is canceled (i.e. only one alarm can be
scheduled at any time). The returned value is then the number
of seconds before any previously set alarm was to have been
delivered. If time is zero, no alarm id scheduled, and any
scheduled alarm is canceled. The return value is the number of
seconds remaining before a previously scheduled alarm. If the
return value is zero, no alarm is currently scheduled. (See the
Unix man page alarm(2).)
signal (signalnum, handler)
Set the handler for signal signalnum to the function handler.
handler can be a callable Python object taking two arguments
(see below), or one of the special values signal.SIG_IGN or
signal.SIG_DFL. The previous signal handler will be returned
(see the description of getsignal() above). (See the Unix man
page signal(2).)
So:
1) read the manual on the signal module
2) create a function according to the manual
3) call the 'alarm' function with 300 (time in seconds) as
argument,
4) use the raw_input function
</quote>
regards,
Gerrit.
--
Plis korekt eni ingglisj joe encounter in mai imeel meeasj!
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----