sockets to block until when the process ends didn't work.
This patch inserts a simple sleep(1) (second) into the code that
waits for the jobs to finish to prevent the queue manager from rapidly
spinning.
It should probably be fixed with a better way of monitoring for when
a process finishes
MERGED from trunk (the hard way)
import subprocess
import select
import sys
import subprocess
import select
import sys
class QueueCommands(object):
"""
class QueueCommands(object):
"""
queue_log.info('using %s as cwd' % (self.cwd,))
while (len(self.to_run) > 0) and self.under_process_limit():
queue_log.info('using %s as cwd' % (self.cwd,))
while (len(self.to_run) > 0) and self.under_process_limit():
+ queue_log.info('%d left to run', len(self.to_run))
cmd = self.to_run.pop(0)
p = subprocess.Popen(cmd, stdout=PIPE, cwd=self.cwd, shell=True)
self.running[p.stdout] = p
cmd = self.to_run.pop(0)
p = subprocess.Popen(cmd, stdout=PIPE, cwd=self.cwd, shell=True)
self.running[p.stdout] = p
pending = self.running[pending_fd]
# if it really did finish, remove it from running jobs
if pending.poll() is not None:
pending = self.running[pending_fd]
# if it really did finish, remove it from running jobs
if pending.poll() is not None:
- queue_log.info("Process %d finished" % (pending.pid,))
+ queue_log.info("Process %d finished [%d]",
+ pending.pid, pending.returncode)
del self.running[pending_fd]
del self.running[pending_fd]