def _stop(self): """ Overridden to call stop on all children """ Task._stop(self) for subtask in self.subtasks: subtask._stop()
def __init__(self, msg=None): Task.__init__(self, msg) self._lock = RLock() # general lock self._subtask = None # subtask that is parallelized self._subtask_class = None # class of subtask self._subtask_args = None # args for initializing subtask self._subtask_kwargs = None # kwargs for initializing subtask self.datasource = DataSource(self.datasource) self.logger = logging.getLogger('root')
def __getattribute__(self, key): """ Overridden to lazy instantiate subtask when requested """ if key == 'subtask': if not self.__dict__['subtask']: subtask = self.__subtask_class(*self.__subtask_args, \ **self.__subtask_kwargs) self.subtask = subtask return self.__dict__['subtask'] return Task.__getattribute__(self, key)
def __init__(self, msg='Demo Task'): Task.__init__(self, msg)
def __init__(self, msg, sequential=True): Task.__init__(self, msg) self.subtasks = [] self.sequential = sequential for task in self.subtasks: task.parent = self
def __init__(self, msg='Demo Task', *args, **kwargs): Task.__init__(self, msg)
def __setattr__(self, key, value): Task.__setattr__(self, key, value) if key == 'subtask' and value: value.parent = self
def __init__(self): self.__pickle_proto = 0 self.__modules = [] self.__objects = {} Task.__init__(self,"FunctionTask")