From b42d4aa0e81e7b4d8376b64605eccaeed35a5cdf Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Tue, 11 Sep 2018 06:54:27 -0700 Subject: [PATCH] Never unclaim a task you've claimed, ensures publisher is always same as drafter This is needed as exact times don't line up between instances --- wubloader/job.py | 4 ++-- wubloader/wubloader.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wubloader/job.py b/wubloader/job.py index cde315c..af86559 100644 --- a/wubloader/job.py +++ b/wubloader/job.py @@ -66,8 +66,8 @@ class Job(object): def cancel(self): """Cancel job that is currently being processed, setting it back to its starting state.""" if not self.worker.ready(): - # By setting uploader to blank, the watchdog will stop the in-progress job. - self.row.update(state=states.FLOWS[self.job_type][0], uploader="") + self.worker.kill(block=False) + self.row.update(state=states.FLOWS[self.job_type][0]) def process(self): """Call this to perform the job.""" diff --git a/wubloader/wubloader.py b/wubloader/wubloader.py index a2c64d7..e195b5e 100644 --- a/wubloader/wubloader.py +++ b/wubloader/wubloader.py @@ -66,7 +66,7 @@ class Wubloader(object): # If it's already claimed, ignore it. # Note this check considers a claim by a dead bot to be invalid. - if job.uploader: + if job.uploader and job.uploader != self.name: continue # If we're not allowed to claim it, ignore it. @@ -114,9 +114,9 @@ class Wubloader(object): """Scan for any existing rows claimed by us, and cancel them.""" for sheet in self.sheets['main'] + self.sheets['chunks']: for row in sheet: - if row.uploader == self.name: - logging.warning("Found existing claimed job for us, clearing") - row.update(uploader="", state=states.rollback(row.state)) + if row.uploader == self.name and row.state != states.rollback(row.state): + logging.warning("Found existing in progress job for us, clearing") + row.update(state=states.rollback(row.state)) def find_jobs(self): """Return potential jobs (based only on state), in priority order."""