Logo Search packages:      
Sourcecode: python-biopython version File versions  Download package

def Bio::PopGen::FDist::Async::SplitFDist::monitor (   self )
Monitors and reports (using report_fun) execution.

   Every time a partial simulation ends, calls report_fun.
   IMPORTANT: monitor calls can be concurrent with other
   events, ie, a tasks might end while report_fun is being
   called. This means that report_fun should be consider that
   other events might be happening while it is running (it
   can call acquire/release if necessary).

Definition at line 96 of file Async.py.

                     :
        """Monitors and reports (using report_fun) execution.

           Every time a partial simulation ends, calls report_fun.
           IMPORTANT: monitor calls can be concurrent with other
           events, ie, a tasks might end while report_fun is being
           called. This means that report_fun should be consider that
           other events might be happening while it is running (it
           can call acquire/release if necessary).
        """
        while(True):
            sleep(1)
            self.async.access_ds.acquire()
            keys =  self.async.done.keys()[:]
            self.async.access_ds.release()
            for done in keys:
                self.async.access_ds.acquire()
                fst, files = self.async.done[done]
                del self.async.done[done]
                out_dat = files['out.dat']
                f = open(self.data_dir + os.sep + 'out.dat','a')
                f.writelines(out_dat.readlines())
                f.close()
                out_dat.close()
                self.async.access_ds.release()
                for file in os.listdir(self.parts[done]):
                    os.remove (self.parts[done] + os.sep + file)
                os.rmdir(self.parts[done])
                #print fst, out_dat
                if self.report_fun:
                    self.report_fun(fst)
            self.async.access_ds.acquire()
            if len(self.async.waiting) == 0 and len(self.async.running) == 0 \
               and len(self.async.done) == 0:
                break
            self.async.access_ds.release()
            #print 'R', self.async.running
            #print 'W', self.async.waiting
            #print 'R', self.async.running


Generated by  Doxygen 1.6.0   Back to index