发布时间:2019-09-18 07:29:46编辑:auto阅读(1604)
http://blog.sina.com.cn/s/blog_63041bb80102uy5o.html
背景:
import timeimport signaldef test(i):time.sleep(i%4)print "%d within time"%(i)return iif __name__ == '__main__':def handler(signum, frame):raise AssertionErrori = 0for i in range(1,10):try:signal.signal(signal.SIGALRM, handler)signal.alarm(3)test(i)i = i + 1signal.alarm(0)except AssertionError:print "%d timeout"%(i)
1 within time2 within time3 timeout4 within time5 within time6 within time7 timeout8 within time9 within time
上一篇: 教你阅读Python开源项目代码
下一篇: ubuntu sublime text3
47840
46386
37279
34731
29312
25970
24909
19949
19541
18026
5790°
6411°
5926°
5960°
7063°
5910°
5942°
6437°
6404°
7776°