Пример #1
0
 def add_task_message(self,task):
     global lock
     print("master dispatch one task to worker")
     print(task)
     crawler_task = Task(task)
     uuid = crawler_task.get_uuid()
     lock.acquire()
     if not self.run_tasks.has_key(uuid):
         crawler_task.port = self.ports.pop()
         self.tasks[uuid] = crawler_task
         lock.release()
     else:
         lock.release()
         status = crawler_task.get_status()
         cfg_name = crawler_task.get_cfg_name("cfg_name")
         if status == TaskStatus.DISPATCH:
             crawler_task.port = self.ports.pop()
         elif status == TaskStatus.SUSPEND:
             #print "pause here :%s %s" % (cfg_name, port)
             socket_send("pause:%s" %cfg_name, crawler_task.get_port())
         elif status == TaskStatus.RUN:
             socket_send("resume:%s" %cfg_name, crawler_task.get_port())