interpreter limits
Joseph T. Bore
jbore at tjtech.com
Wed Apr 14 16:02:53 EDT 2004
There is probably a better solution but this worked for me, thanks
Irmen!
jb
----------------------------------------
import signal
def alarmHandler(signum, frame):
raise TimeExceededError, "Your command ran too long"
def infinite():
while 1:
pass
#
# code to wrap a function call which may take too long...
#
signal.signal(signal.SIGALRM, alarmHandler)
signal.alarm(1)
try:
# call a function that never returns
infinite()
except TimeExceededError:
print "code must have gone crazy..."
signal.alarm(0)
----------------------------------------
More information about the Python-list
mailing list