Changeset 238 for tbroadcast


Ignore:
Timestamp:
Aug 26, 2006, 2:48:07 PM (18 years ago)
Author:
garonne
Message:

check cycles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tbroadcast/v2/python/tbroadcast.py

    r237 r238  
    2525        self.pool     = ThreadPool(num_workers=num_workers)
    2626        self.packages = {} 
     27        self.check_cycles()
    2728        self.instanciate_packages ()     
    2829
     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   
    2948    def instanciate_packages(self):
    3049        # We create the schedule of the work units
    31         print '# first, we initialize the DAG (takes a long time... 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) '
    3251        cmd = 'cmt show uses'
    3352        status, output = commands.getstatusoutput (cmd)
     
    4564                if name not in self.packages[current_package]['dependencies']:
    4665                   self.packages[current_package]['dependencies'].append (name)               
    47                    print '\n#', indice,':: add package', name
     66                   #print '\n#', indice,':: add package', name
    4867                   indice = indice + 1
    4968                if not self.packages.has_key (name):
     
    5675                               if string.split (ligne)[2] not in self.packages[name]['dependencies']:
    5776                                   self.packages[name]['dependencies'].append (string.split (ligne)[2])
    58                                    print "# add dependency", string.split (ligne)[2], ' to package ',name
     77                                   #print "# add dependency", string.split (ligne)[2], ' to package ',name
    5978                           else:
    6079                                found = False                                                                                                   
     
    97116                        sys.exit(-1)
    98117                    self.packages[result[0]]['path'] = full_path
    99         print '# really takes a long time... '
     118        print '# really takes a certain time ... '
    100119
    101120    def get_current_package(self):   
     
    150169                result.append(key)
    151170        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       
    152178
    153179    def suppress_work_unit (self, name):
     
    168194
    169195    def execute (self, command):
    170         self.print_dependencies ()
     196        #self.print_dependencies ()
    171197        packages = self.get_next_work_units()
    172198        if len(packages) !=0:
    173199            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)
    176202
    177203    def execute_all(self,command):
    178204        self.execute (command)
    179205        self.wait()
     206        while self.is_work_units():
     207            self.wait()   
    180208       
    181209    def wait (self):
Note: See TracChangeset for help on using the changeset viewer.