Python之signal模块

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
print 'Timeout caught'
上一篇:hibernate的对象状态分析


下一篇:Spring事务管理源码分析