[project @ Bypass pipe lock mystery bug for configure step]
authorBrandon King <kingb@caltech.edu>
Tue, 11 Dec 2007 21:43:19 +0000 (21:43 +0000)
committerBrandon King <kingb@caltech.edu>
Tue, 11 Dec 2007 21:43:19 +0000 (21:43 +0000)
 * There was a weird bug where certain failures of the pipeline could
   leave the configure_run.py configure code waiting for output from the
   configuration pipe, but where the program has already finished... leaving
   the configure step stuck in a perminate state of waiting.
 * This patch bypasses this problem by passing subprocess.Popen file
   descriptors instead of subproccess.PIPE and then processing the
   output after the program has terminated. I have never seen the
   mystery bug when using this approach. This is how the run pipeline
   step already handles running the pipeline and is also where I first
   encountered this problem.

gaworkflow/pipeline/configure_run.py

index a0d8c33285fda74d617a48984f509a5147bbcd7b..448576d1ec5b846d3374a89461b06b330605b0f5 100644 (file)
@@ -436,33 +436,54 @@ def configure(conf_info):
 
   # CONTINUE HERE
   #FIXME: this only does a run on 5 tiles on lane 4
+
+  stdout_filepath = "pipeline_configure_stdout.txt"
+  stderr_filepath = "pipeline_configure_stderr.txt"
+
+  fout = open(stdout_filepath, 'w')
+  ferr = open(stderr_filepath, 'w')
+  
   pipe = subprocess.Popen(['goat_pipeline.py',
                     '--GERALD=%s' % (conf_info.config_filepath),
                            #'--tiles=s_4_0100,s_4_0101,s_4_0102,s_4_0103,s_4_0104',
                            '--make',
                            '.'],
-                          stdout=subprocess.PIPE,
-                          stderr=subprocess.PIPE)
+                          stdout=fout,
+                          stderr=ferr)
+
+  print "Configuring pipeline: %s" % (time.ctime())
+  error_code = pipe.wait()
+
+  # Clean up
+  fout.close()
+  ferr.close()
+  
+  
   ##################
   # Process stdout
-  stdout_line = pipe.stdout.readline()
+  fout = open(stdout_filepath, 'r')
+  
+  stdout_line = fout.readline()
 
   complete = False
   while stdout_line != '':
     # Handle stdout
     if config_stdout_handler(stdout_line, conf_info):
       complete = True
-    stdout_line = pipe.stdout.readline()
+    stdout_line = fout.readline()
+
+  fout.close()
 
 
-  error_code = pipe.wait()
+  #error_code = pipe.wait()
   if error_code:
     logging.error('Recieved error_code: %s' % (error_code))
   else:
     logging.info('We are go for launch!')
 
   #Process stderr
-  stderr_line = pipe.stderr.readline()
+  ferr = open(stderr_filepath, 'r')
+  stderr_line = ferr.readline()
 
   abort = 'NO!'
   stderr_success = False
@@ -472,7 +493,9 @@ def configure(conf_info):
       abort = RUN_ABORT
     elif stderr_status is True:
       stderr_success = True
-    stderr_line = pipe.stderr.readline()
+    stderr_line = ferr.readline()
+
+  ferr.close()
 
 
   #Success requirements: