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
archive/original-v2.1
Mike Lang 6 years ago
parent 7c8045bc11
commit b42d4aa0e8

@ -66,8 +66,8 @@ class Job(object):
def cancel(self): def cancel(self):
"""Cancel job that is currently being processed, setting it back to its starting state.""" """Cancel job that is currently being processed, setting it back to its starting state."""
if not self.worker.ready(): if not self.worker.ready():
# By setting uploader to blank, the watchdog will stop the in-progress job. self.worker.kill(block=False)
self.row.update(state=states.FLOWS[self.job_type][0], uploader="") self.row.update(state=states.FLOWS[self.job_type][0])
def process(self): def process(self):
"""Call this to perform the job.""" """Call this to perform the job."""

@ -66,7 +66,7 @@ class Wubloader(object):
# If it's already claimed, ignore it. # If it's already claimed, ignore it.
# Note this check considers a claim by a dead bot to be invalid. # 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 continue
# If we're not allowed to claim it, ignore it. # 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.""" """Scan for any existing rows claimed by us, and cancel them."""
for sheet in self.sheets['main'] + self.sheets['chunks']: for sheet in self.sheets['main'] + self.sheets['chunks']:
for row in sheet: for row in sheet:
if row.uploader == self.name: if row.uploader == self.name and row.state != states.rollback(row.state):
logging.warning("Found existing claimed job for us, clearing") logging.warning("Found existing in progress job for us, clearing")
row.update(uploader="", state=states.rollback(row.state)) row.update(state=states.rollback(row.state))
def find_jobs(self): def find_jobs(self):
"""Return potential jobs (based only on state), in priority order.""" """Return potential jobs (based only on state), in priority order."""

Loading…
Cancel
Save