Further changes to make sure drafts and chunks can still be unclaimed

archive/original-v2.1
Mike Lang 6 years ago
parent 8848b24208
commit 291b947e5b

@ -74,6 +74,8 @@ class Job(object):
if not self.worker.ready(): if not self.worker.ready():
self.worker.kill(block=False) self.worker.kill(block=False)
self.row.update(state=states.FLOWS[self.job_type][0]) self.row.update(state=states.FLOWS[self.job_type][0])
if self.job_type != 'publish':
self.row.update(uploader="")
def process(self): def process(self):
"""Call this to perform the job.""" """Call this to perform the job."""

@ -64,7 +64,7 @@ class Wubloader(object):
while not self.stopping: while not self.stopping:
for job in self.find_jobs(): for job in self.find_jobs():
# If it's already claimed, ignore it. # If it's already claimed (except by us), ignore it.
# Note this check considers a claim by a dead bot to be invalid (except for publishes). # Note this check considers a claim by a dead bot to be invalid (except for publishes).
if job.uploader and job.uploader != self.name: if job.uploader and job.uploader != self.name:
continue continue
@ -111,12 +111,13 @@ class Wubloader(object):
self.stopped.set() self.stopped.set()
def cleanup_existing(self): def cleanup_existing(self):
"""Scan for any existing rows claimed by us, and cancel them.""" """Scan for any existing non-publish rows claimed by us, and cancel them."""
for sheet in self.sheets['main'] + self.sheets['chunks']: for job in self.find_jobs():
for row in sheet: if job.row.uploader == self.name and job.row.state != states.rollback(job.row.state):
if row.uploader == self.name and row.state != states.rollback(row.state): logging.warning("Found existing in progress job for us, clearing")
logging.warning("Found existing in progress job for us, clearing") job.row.update(state=states.rollback(job.row.state))
row.update(state=states.rollback(row.state)) if job.job_type != 'publish':
job.row.update(uploader="")
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