def startwork():
        co_routines = []
        co_routines_status = 1
        for iNum in range(config.THREAD_NUM):
            worker = AlsWorker(config, log, iNum,view_name_list)
            work = gevent.spawn(worker.handle_tasks)
            co_routines.append(work)
        list_ippath = get_handlefilepath(config)
        for strippath in list_ippath:
            put_querywork(strippath)

        while 1:
            if tasks_workqueue.empty():
                co_statussem.acquire()
                co_routines_status = 0
                co_statussem.release()
                break
            if is_sigint_up:
                gevent.shutdown()
                break
            gevent.sleep(10)
        gevent.joinall(co_routines)
        out_result()  
Beispiel #2
0
 def handle_tasks(self):
     #print "work:%dstart" %(self.workid)
     gevent.sleep(0)
     #等待任务队列
     while 1:
         #如果处理队列为空, 则不处理
         if not tasks_workqueue.empty():
             taskinfo = tasks_workqueue.get()
             self.log.debug("WORKID%d:%s" %(self.workid,taskinfo))
             if os.path.exists(taskinfo):
                 #处理日志
                 self.read_gz_file(taskinfo)
             if self.dir_tmp:
                 self.sync_data()
             self.dir_tmp.clear()
             #gevent.sleep(5)
         else:
             co_statussem.acquire()
             if co_routines_status:
                 co_statussem.release()
                 gevent.sleep(2)
                 continue
             co_statussem.release()
             break