http://www.cnblogs.com/dkblog/archive/2011/03/07/1980636.html
1、超时处理
#!/usr/bin/env python2.7
#-*- coding:utf8 -*- import signal def handler(signum,frame):
print 'Signal handler called with signal',signum
raise TimeOutError,"TimeOut!" try:
signal.signal(signal.SIGALRM,handler)
signal.alarm(1) while True:
print 'a'
signal.alarm(0)
except:
print 'Timeout caught'