Skip to content

Commit

Permalink
Catch all errors in worker process and log it, don't crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas committed Jul 9, 2010
1 parent 6aacd81 commit 4defbec
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions django_beanstalkd/management/commands/beanstalk_worker.py
@@ -1,3 +1,4 @@
import logging
from optparse import make_option
import os
import sys
Expand Down Expand Up @@ -104,9 +105,20 @@ def work(self):
job = beanstalk.reserve()
job_name = job.stats()['tube']
if job_name in self.jobs:
#print "Calling %s with arg: %s" % (job_name, job.body)
self.jobs[job_name](job.body)
job.delete()
logging.debug("Calling %s with arg: %s" % (job_name, job.body))
try:
self.jobs[job_name](job.body)
except Exception, e:
logging.error('Error while calling "%s" with arg "%s": '
'%s' % (
job_name,
job.body,
e,
)
)
job.bury()
else:
job.delete()
else:
job.release()

Expand Down

0 comments on commit 4defbec

Please sign in to comment.