Changeset 238 for tbroadcast/v2/python
- Timestamp:
- Aug 26, 2006, 2:48:07 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tbroadcast/v2/python/tbroadcast.py
r237 r238 25 25 self.pool = ThreadPool(num_workers=num_workers) 26 26 self.packages = {} 27 self.check_cycles() 27 28 self.instanciate_packages () 28 29 30 31 def check_cycles (self): 32 cmd = 'cmt show cycles' 33 cycle_found = False 34 status, output = commands.getstatusoutput (cmd) 35 if status != 0: 36 print output 37 sys.exit(-1) 38 lines = string.split(output, '\n') 39 for line in lines: 40 if line [0] != '#': 41 if not cycle_found: 42 cycle_found = True 43 print "# Error: cycles found, not possible to execute broadcast with threads. See the followings packages:" 44 print line 45 if cycle_found: 46 sys.exit(-1) 47 29 48 def instanciate_packages(self): 30 49 # We create the schedule of the work units 31 print '# first, we initialize the DAG (takes a longtime... huk should be improved asap) '50 print '# First, we initialize the DAG by parsing cmt show uses (takes a certain time... huk should be improved asap) ' 32 51 cmd = 'cmt show uses' 33 52 status, output = commands.getstatusoutput (cmd) … … 45 64 if name not in self.packages[current_package]['dependencies']: 46 65 self.packages[current_package]['dependencies'].append (name) 47 print '\n#', indice,':: add package', name66 #print '\n#', indice,':: add package', name 48 67 indice = indice + 1 49 68 if not self.packages.has_key (name): … … 56 75 if string.split (ligne)[2] not in self.packages[name]['dependencies']: 57 76 self.packages[name]['dependencies'].append (string.split (ligne)[2]) 58 print "# add dependency", string.split (ligne)[2], ' to package ',name77 #print "# add dependency", string.split (ligne)[2], ' to package ',name 59 78 else: 60 79 found = False … … 97 116 sys.exit(-1) 98 117 self.packages[result[0]]['path'] = full_path 99 print '# really takes a long time... '118 print '# really takes a certain time ... ' 100 119 101 120 def get_current_package(self): … … 150 169 result.append(key) 151 170 return result 171 172 def is_work_units (self): 173 result = list () 174 for key in self.packages.keys(): 175 if self.is_work_unit_waiting(key) : 176 return True 177 return False 152 178 153 179 def suppress_work_unit (self, name): … … 168 194 169 195 def execute (self, command): 170 self.print_dependencies ()196 #self.print_dependencies () 171 197 packages = self.get_next_work_units() 172 198 if len(packages) !=0: 173 199 print '\n# Execute parallel actions within ', packages 174 for package in packages:175 self.add_work_unit (package, command)200 for package in packages: 201 self.add_work_unit (package, command) 176 202 177 203 def execute_all(self,command): 178 204 self.execute (command) 179 205 self.wait() 206 while self.is_work_units(): 207 self.wait() 180 208 181 209 def wait (self):
Note: See TracChangeset
for help on using the changeset viewer.