11#!/usr/bin/env python3
22import os
3+ import subprocess
4+ import threading
35import sys
46import shlex
57import tempfile
@@ -103,7 +105,8 @@ for line in f:
103105 if NO_PROCESSING_MODE and len (args ) > 2 :
104106 print ('Cannot use DPL workflow together with DD mode' , os .environ ['DDMODE' ])
105107 raise
106- for i in range (2 , len (args )):
108+
109+ def processSubtopology (i , args , tmpdir , reconodes , reconodesmin , recoworkflows , calibworkflows , calibworkflowsdds ):
107110 filename = tmpdir + '/wf' + str (i ) + '.dds'
108111 calibcores = '1'
109112 if args [i ].startswith ('reco' ):
@@ -131,8 +134,8 @@ for line in f:
131134 if os .environ ['WORKFLOWMODE' ] == 'print' :
132135 command += ' > ' + filename
133136 print ('Running DPL command' , command )
134- retVal = os . system (command )
135- if retVal != 0 :
137+ retVal = subprocess . run (command , shell = True )
138+ if retVal . returncode != 0 :
136139 print ('Error (' + str (retVal ) + ') running command' , command )
137140 ftmp = open (filename , 'r' )
138141 rg = re .compile ('^<topology' )
@@ -153,9 +156,17 @@ for line in f:
153156 isempty = 0
154157 break
155158 if isempty :
156- continue
159+ return
157160 calibworkflows .append (filename )
158161 calibworkflowsdds .append (filename + ':' + calibcores )
162+
163+ subtopologyThreads = []
164+ for i in range (2 , len (args )):
165+ t = threading .Thread (target = processSubtopology , args = (i , args , tmpdir , reconodes , reconodesmin , recoworkflows , calibworkflows , calibworkflowsdds ))
166+ t .start ()
167+ subtopologyThreads .append (t )
168+ for t in subtopologyThreads :
169+ t .join ()
159170 if reco_num_nodes_override > 0 :
160171 reconodes = reco_num_nodes_override
161172 reconodesmin = min (reconodes , reconodesmin )
0 commit comments