Skip to content

Commit

Permalink
Only retry jobs 5 times. Need to add scheduling so retries can be don…
Browse files Browse the repository at this point in the history
…e later.
  • Loading branch information
samuel committed Nov 28, 2009
1 parent b912750 commit 550d353
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions dreque/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ def work(self, interval=5):
if interval == 0:
break
time.sleep(interval)
continue

try:
self.working_on(job)
self.process(job)
except Exception, exc:
self.log.info("Job failed (%s): %s" % (job, str(exc)))
import traceback
self.log.info("Job failed (%s): %s\n%s" % (job, str(exc), traceback.format_exc()))
# Requeue
queue = job.pop("queue")
self.push(queue, job)
if 'fails' not in job:
job['fails'] = 1
else:
job['fails'] += 1
if job['fails'] < 5:
self.push(queue, job)
self.failed()
else:
self.done_working()
Expand Down Expand Up @@ -85,7 +92,7 @@ def lookup_function(self, name):
return self.function_cache[name]
except KeyError:
mod_name, func_name = name.rsplit('.', 1)
mod = __import__(mod_name, {}, {}, [func_name])
mod = __import__(str(mod_name), {}, {}, [str(func_name)])
func = getattr(mod, func_name)
self.function_cache[name] = func
return func
Expand Down

0 comments on commit 550d353

Please sign in to comment.