返回信息流如题,为什么我下面的方法无法终止多进程呢
#!/usr/local/bin
# coding=utf-8
import multiprocessing
import signal
import time
processPool = []
class test(multiprocessing.Process):
def __init__(self):
multiprocessing.Process.__init__(self)
self.flag = True
def run(self):
while self.flag:
print self.flag
time.sleep(6)
print self.flag
def stop(self):
print 'stop process'
self.flag = False
def sigint_handler(signum,frame):
global processPool
for p in processPool:
p.stop()
if __name__=='__main__':
signal.signal(signal.SIGINT,sigint_handler)
signal.signal(signal.SIGHUP,sigint_handler)
signal.signal(signal.SIGTERM,sigint_handler)
for i in range(1):
p = test()
p.start()
processPool.append(p)
for p in processPool:
p.join()
这是一条镜像帖。来源:北邮人论坛 / python / #2869同步于 2014/8/12
Python机器人发帖
[问题]如何终止多进程呢
century
2014/8/12镜像同步0 回复
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。