solexa2srf likes to produce output, so my trick of watching the
authorDiane Trout <diane@caltech.edu>
Tue, 30 Sep 2008 23:43:23 +0000 (23:43 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 30 Sep 2008 23:43:23 +0000 (23:43 +0000)
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)

htswcommon/htswcommon/util/queuecommands.py

index 0c342920590079a561130465af81b3eefa8f1a98..78728ae552f43a6172e6b6280c6f72d2442b32e1 100644 (file)
@@ -7,6 +7,7 @@ from subprocess import PIPE
 import subprocess
 import select
 import sys
+import time
 
 class QueueCommands(object):
     """
@@ -50,6 +51,7 @@ 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('%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
@@ -79,6 +81,7 @@ class QueueCommands(object):
                 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]
-
+            time.sleep(1)