示例#1
0
文件: server.py 项目: HyFrmn/Wrangler
 def request_task(self):
     self.debug('Requesting task from server.')
     taskid = self.client.next_task(self.hostname)
     if taskid > 0:
         self.info('Task %d was received from server.' % taskid)
         db = Session()
         task = db.query(Task).filter_by(id=taskid).first()
         db.expunge(task)
         db.close()
         if task:
             self.num_thread_lock.acquire()
             self.running_tasks[taskid] = task
             self.num_thread_lock.release()
             self._pre_task(task)
             if not self._run_task(task):
                 self._clean_up_task(task)
             self._no_tasks = False
     else:
         self.debug('No task was received from server.')
         self._no_tasks = True
示例#2
0
文件: server.py 项目: HyFrmn/Wrangler
 def monitor_probe(self, task_id, probes):
     self.debug("Logging probe for %d" % task_id)
     task = self.running_tasks[task_id]
     db = Session()
     probe = TaskProbe()
     db.add(probe)
     cattle = self.cattle
     probe.task_id = task_id
     probe.memory = probes['memory']
     probe.pcpu = probes['pcpu']
     probe.pid = probes['pid']
     #probe.cattle_id = task.log.cattle_id
     probe.time = datetime.datetime.now()
     probe.probes = probes
     probe.cattle_id = cattle.id
     probe.task_log_id = task.log.id
     db.commit()
     probe_id = probe.id
     db.expunge(probe)
     db.close()
     return probe_id