线程,子过程&僵尸

时间:2009-07-19 16:22:19

标签: timer subprocess zombie-process

我需要使用线程和SSH在精确的时刻分别启动多个远程作业。所以我写道:

def dojob(hostname):

    command = "echo Done"
    p = Popen(['ssh','%s@%s' % (user, hostname), command], stdout=PIPE, shell=False)
    output = p.communicate()[0].strip()
    print output

[...]

fire_starter = [Timer(t, dojob, [y]) for t,y in zip(instant, hosts)]

for e in fire_starter:
    e.start()

代码可以工作,但是我的操作系统充斥着Zombies。老实说,我相信通信()方法负责子进程,等待它终止。我哪里错了?

1 个答案:

答案 0 :(得分:1)

看起来你遇到了与pipe / ssh和popen()相关的this issue。有一个分析和解决方案here

相关问题