views:

223

answers:

1

Hi,

I need to launch several remote jobs each at a precise moment using threads and SSH. So I write:

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()

The code works, but it floods my OS with Zombies. Honestly, I believed that the communicate() method takes care of the child process, waiting for it to terminate. Where am I wrong ?

+1  A: 

Looks like you've run into this issue relating to pipes/ssh and popen(). There's an analysis and resolution here.

Brian Agnew