def __init__(self,name,queue,condition):
     #self._ret_data = ReturnData()
     threading.Thread.__init__(self,name=name)
     self._queue = queue
     self._cond = condition
     self._stopEvent = threading.Event()
     self._task_fetch = TaskProcess()
class AgentTaskFetch(threading.Thread):
    
    def __init__(self,name,queue,condition):
        #self._ret_data = ReturnData()
        threading.Thread.__init__(self,name=name)
        self._queue = queue
        self._cond = condition
        self._stopEvent = threading.Event()
        self._task_fetch = TaskProcess()
    
    def run(self):
        while not self._stopEvent.isSet():
            self._cond.acquire()
            while not self._queue.empty():
                self._cond.wait()
            ret_list = self._task_fetch.read_unprocess_task()
            for item in ret_list:
                self._queue.put(item)
            #self._queue.queue.clear()
            #TODO:add item into queue
            #for i in xrange(10):
            #    log("loop times:%d"%i)
            #    self._queue.put(random.randint(100,200))
            log("[AgentTaskFetch]queue info:%s"%str(self._queue))
            self._cond.notifyAll()
            self._cond.release()
            
            time.sleep(5)
        #step-1:check params
        #DownLoadFile().download_from_remote(pkg_path="", pkg_name="manual.tar.gz", md5_info="956eb64566c79f483920fa3aa3b0a03c")
        #step-2:write info into db or file
        
    def stop(self):
        self._stopEvent.set()