<s> import threading <EOL> from django . conf import settings <EOL> import taskforce <EOL> class BaseTask ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . _lock = threading . RLock ( ) <EOL> self . _status = taskforce . TASK_STATUS . WAITING <EOL> self . _progress = None <EOL> self . _results = None <EOL> def _get_status ( self ) : <EOL> if self . _lock . acquire ( ) : <EOL> try : <EOL> return self . _status <EOL> finally : <EOL> self . _lock . release ( ) <EOL> def _set_status ( self , status ) : <EOL> if self . _lock . acquire ( ) : <EOL> try : <EOL> self . _status = status <EOL> finally : <EOL> self . _lock . release ( ) <EOL> status = property ( _get_status , _set_status ) <EOL> def _get_progress ( self ) : <EOL> if self . _lock . acquire ( ) : <EOL> try : <EOL> return self . _progress <EOL> finally : <EOL> self . _lock . release ( ) <EOL> def _set_progress ( self , progress ) : <EOL> if self . _lock . acquire ( ) : <EOL> try : <EOL> self . _progress = progress <EOL> finally : <EOL> self . _lock . release ( ) <EOL> progress = property ( _get_progress , _set_progress ) <EOL> def _get_results ( self ) : <EOL> if self . _lock . acquire ( ) : <EOL> try : <EOL> return self . _results <EOL> finally : <EOL> self . _lock . release ( ) <EOL> def _set_results ( self , results ) : <EOL> if self . _lock . acquire ( ) : <EOL> try : <EOL> self . _results = results <EOL> finally : <EOL> self . _lock . release ( ) <EOL> results = property ( _get_results , _set_results ) <EOL> def _start ( self , run_args = ( ) , run_kwargs = { } ) : <EOL> def _new_start ( ) : <EOL> self . _results = self . run ( * run_args , ** run_kwargs ) <EOL> self . _start = _new_start <EOL> def run ( self ) : <EOL> "<STR_LIT>" <EOL> pass </s>
