Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.PopGen.Async.Local.Local Class Reference
Inheritance diagram for Bio.PopGen.Async.Local.Local:
Inheritance graph
[legend]
Collaboration diagram for Bio.PopGen.Async.Local.Local:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def start_work
def run_program
def get_result

Public Attributes

 num_cores
 cores_used
 running
 waiting
 done
 id
 hooks
 access_ds

Private Member Functions

def _run_program

Detailed Description

Execution on Local machine.

Definition at line 16 of file Local.py.


Constructor & Destructor Documentation

def Bio.PopGen.Async.Local.Local.__init__ (   self,
  num_cores = 1 
)
Constructor.

   parameters:
   num_cores - Number of cores (for multiprocessor machines,
       multiply accordingly)

Definition at line 20 of file Local.py.

00020 
00021     def __init__(self, num_cores = 1):
00022         '''Constructor.
00023 
00024            parameters:
00025            num_cores - Number of cores (for multiprocessor machines,
00026                multiply accordingly)
00027         '''
00028         Async.__init__(self)
00029         self.num_cores = num_cores
00030         self.cores_used = 0


Member Function Documentation

def Bio.PopGen.Async.Local.Local._run_program (   self,
  id,
  hook,
  parameters,
  input_files 
) [private]
Run program.

   For parameters, please check Async.run_program.

   Either runs a program if a core is available or
   schedules it.

Reimplemented from Bio.PopGen.Async.Async.

Definition at line 31 of file Local.py.

00031 
00032     def _run_program(self, id, hook, parameters, input_files):
00033         '''Run program.
00034 
00035            For parameters, please check Async.run_program.
00036 
00037            Either runs a program if a core is available or
00038            schedules it.
00039         '''
00040         self.access_ds.acquire()
00041         self.waiting.append((id, hook, parameters, input_files))
00042         if self.cores_used < self.num_cores:
00043             self.cores_used += 1
00044             thread.start_new_thread(self.start_work, ())
00045         self.access_ds.release()

Here is the call graph for this function:

def Bio.PopGen.Async.Async.get_result (   self,
  id 
) [inherited]
Returns the results for a certain Id, the info for that Id is
    forgotten.

    parameters:
    id Id of the task.

    returns:
    (return_code, output_files) return code and file access
    object.

    The output_files hash key is a relative file name, and the value a
    output stream.

Definition at line 70 of file __init__.py.

00070 
00071     def get_result(self, id):
00072         ''' Returns the results for a certain Id, the info for that Id is
00073             forgotten.
00074 
00075             parameters:
00076             id Id of the task.
00077 
00078             returns:
00079             (return_code, output_files) return code and file access
00080             object.
00081 
00082             The output_files hash key is a relative file name, and the value a
00083             output stream.
00084         '''
00085         self.access_ds.acquire()
00086         if id in self.done:
00087             returnCode, fileObject = self.done[id]
00088             del self.done[id]
00089             self.access_ds.release()
00090         else:
00091             self.access_ds.release()
00092             return None

def Bio.PopGen.Async.Async.run_program (   self,
  program,
  parameters,
  input_files 
) [inherited]
Runs a program.

   Real _run_program to be implemented by concrete classes.

   parameters:
   program String identifying program.
   parameters List of String parameters.
   input_files Hash of Input file descriptors.

   returns:
   Task Id.

   The input_files hash key is the path that is passed
   to the program. It should always be relative.
   Value is a stream.

Definition at line 37 of file __init__.py.

00037 
00038     def run_program(self, program, parameters, input_files):
00039         '''Runs a program.
00040         
00041            Real _run_program to be implemented by concrete classes.
00042 
00043            parameters:
00044            program String identifying program.
00045            parameters List of String parameters.
00046            input_files Hash of Input file descriptors.
00047 
00048            returns:
00049            Task Id.
00050 
00051            The input_files hash key is the path that is passed
00052            to the program. It should always be relative.
00053            Value is a stream.
00054         '''
00055         if program in self.hooks:
00056             self.access_ds.acquire()
00057             self.id += 1
00058             id = self.id
00059             self.access_ds.release()
00060             self._run_program(id, self.hooks[program], parameters, input_files)
00061             return id

Here is the call graph for this function:

Starts work.

   Thread initial point.
   While there are tasks to be done, runs them.
   The thread dies as soon as there is nothing waiting to be
   executed.

Definition at line 46 of file Local.py.

00046 
00047     def start_work(self):
00048         '''Starts work.
00049 
00050            Thread initial point.
00051            While there are tasks to be done, runs them.
00052            The thread dies as soon as there is nothing waiting to be
00053            executed.
00054         '''
00055         self.access_ds.acquire()
00056         while (len(self.waiting) > 0):
00057             id, hook, parameters, input_files = self.waiting[0]
00058             del self.waiting[0]
00059             self.running[id] = True
00060             self.access_ds.release()
00061             ret_code, output_files = hook.run_job(parameters, input_files)
00062             self.access_ds.acquire()
00063             del self.running[id]
00064             self.done[id] = ret_code, output_files
00065         self.cores_used -= 1
00066         self.access_ds.release()
00067   

Here is the caller graph for this function:


Member Data Documentation

Definition at line 35 of file __init__.py.

Definition at line 29 of file Local.py.

Definition at line 32 of file __init__.py.

Definition at line 34 of file __init__.py.

Definition at line 33 of file __init__.py.

Definition at line 28 of file Local.py.

Definition at line 30 of file __init__.py.

Definition at line 31 of file __init__.py.


The documentation for this class was generated from the following file: