【发布时间】:2010-11-12 02:57:48
【问题描述】:
我需要使用线程和 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()
代码有效,但它让我的操作系统充斥着僵尸。老实说,我相信communicate() 方法负责处理子进程,等待它终止。我哪里错了?
【问题讨论】:
标签: timer subprocess zombie-process