我正在安装 SIGPROF 信号并每 2 秒执行一次处理程序。有什么问题吗?
1 #!/usr/bin/env python
2 #-*-coding: utf-8 -*-
3 #pylint: disable=W0141,W0613,W0603
4
5 import os
6 import sys
7 import signal
8 import time
9
10 def myhandler(signum, frame):
11 print "myhandler"
12 sys.stdout.flush()
13
14 signal.signal(signal.SIGPROF, myhandler)
15 signal.setitimer(signal.ITIMER_PROF, 2, 2)
16 print signal.getitimer(signal.ITIMER_PROF)
17
18 while True:
19 print "sleeping 1..."
20 sys.stdout.flush()
21 time.sleep(1)