Skip to content
This repository has been archived by the owner on Feb 12, 2020. It is now read-only.

Commit

Permalink
Store string representation of job error
Browse files Browse the repository at this point in the history
instead of error instance, to avoid issue when unpickling certain strange error types.
  • Loading branch information
gotcha committed May 3, 2013
1 parent 4db69b3 commit 8d6ebcc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions docs/HISTORY.txt
Expand Up @@ -4,13 +4,13 @@ Changelog
0.2.1 (unreleased)
------------------

- Nothing changed yet.

- Store string representation of job error instead of error instance,
to avoid issue when unpickling certain strange error types.

0.2.0 (2012-11-12)
------------------

- Simplify start service code; get rid of start * services
- Simplify start service code; get rid of start * services.


0.1-alpha-4 (2011-05-16)
Expand All @@ -28,10 +28,10 @@ Changelog
0.1-alpha-2 (2010-10-19)
------------------------

- Removed use of `_p_jar`
- Removed use of `_p_jar`.


0.1-alpha-1 (2010-09-27)
------------------------

- Initial release
- Initial release.
8 changes: 4 additions & 4 deletions src/z3c/taskqueue/baseservice.py
Expand Up @@ -143,7 +143,7 @@ def getResult(self, jobid):

def getError(self, jobid):
"""See interfaces.ITaskService"""
return str(self.jobs[jobid].error)
return self.jobs[jobid].error

def hasJobsWaiting(self, now=None):
"""
Expand Down Expand Up @@ -195,7 +195,7 @@ def processNext(self, now=None, jobid=None):
except ComponentLookupError, error:
log.error('Task "%s" not found!' % job.task)
log.exception(error)
job.error = error
job.setError(error)
if job.status != interfaces.CRONJOB:
job.status = interfaces.ERROR
return True
Expand All @@ -208,7 +208,7 @@ def processNext(self, now=None, jobid=None):
if job.status != interfaces.CRONJOB:
job.status = interfaces.COMPLETED
except task.TaskError, error:
job.error = error
job.setError(error)
if job.status != interfaces.CRONJOB:
job.status = interfaces.ERROR
except Exception, error:
Expand All @@ -218,7 +218,7 @@ def processNext(self, now=None, jobid=None):
log.exception(str(error))
raise
else:
job.error = error
job.setError(error)
if job.status != interfaces.CRONJOB:
job.status = interfaces.ERROR
else:
Expand Down
3 changes: 3 additions & 0 deletions src/z3c/taskqueue/job.py
Expand Up @@ -51,6 +51,9 @@ def __init__(self, id, task, input):
def __repr__(self):
return '<%s %r>' % (self.__class__.__name__, self.id)

def setError(self, error):
self.error = str(error)


class CronJob(Job):
"""A job for reocuring tasks"""
Expand Down
2 changes: 0 additions & 2 deletions src/z3c/taskqueue/startlater.txt
Expand Up @@ -95,5 +95,3 @@ the ``startLater=True`` parameter.
{'foo': 'bar'}

>>> service.getError(jobid)
'None'

0 comments on commit 8d6ebcc

Please sign in to comment.