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."""