Esempio n. 1
0
    def failed_task(self, run_id, task_id, unique_key):
        run = self.get_run(run_id)
        task = run["tasks"][task_id]
        if DEBUG:
            print(
                "Failed: https://tests.stockfishchess.org/tests/view/{} {} {}".
                format(run_id, task if DEBUG else task_id,
                       get_worker_key(task)),
                flush=True,
            )
        if task_id >= len(run["tasks"]):
            return {"task_alive": False}

        if not task["active"] or not task["pending"]:
            return {"task_alive": False}

        # Test if the task is reallocated to a different worker.
        if task["worker_info"]["unique_key"] != unique_key:
            return {"task_alive": False}

        # Mark the task as inactive: it will be rescheduled
        print(
            "Inactive: https://tests.stockfishchess.org/tests/view/{} {} {}".
            format(run_id, task if DEBUG else task_id, get_worker_key(task)),
            flush=True,
        )
        task["active"] = False
        self.buffer(run, True)
        return {}
Esempio n. 2
0
 def beat(self):
     self.require_authentication()
     if self.task_id() is not None:
         run = self.request.rundb.get_run(self.run_id())
         task = run["tasks"][self.task_id()]
         task["last_updated"] = datetime.utcnow()
         self.request.rundb.buffer(run, False)
         return get_worker_key(task)
     return "Pleased to hear from you..."
Esempio n. 3
0
 def scavenge(self, run):
     if datetime.utcnow() < boot_time + timedelta(seconds=150):
         return False
     # print("scavenge ", run["_id"])
     dead_task = False
     old = datetime.utcnow() - timedelta(minutes=3)
     task_id = -1
     for task in run["tasks"]:
         task_id += 1
         if task["active"] and task["last_updated"] < old:
             task["active"] = False
             dead_task = True
             print(
                 "dead task: run: https://tests.stockfishchess.org/tests/view/{} task_id: {} worker: {}"
                 .format(run["_id"], task_id, get_worker_key(task)),
                 flush=True,
             )
     return dead_task