Don't log job exceptions twice (#1746)

* Don't log job exceptions twice

* Preserve traceback while encountering deserialization error
main
Selwin Ong 2 years ago committed by GitHub
parent 62acd56c91
commit d0e832181f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1164,6 +1164,7 @@ class Worker:
def handle_exception(self, job: 'Job', *exc_info):
"""Walks the exception handler stack to delegate exception handling."""
exc_string = ''.join(traceback.format_exception(*exc_info))
# If the job cannot be deserialized, it will raise when func_name or
@ -1175,14 +1176,17 @@ class Worker:
'arguments': job.args,
'kwargs': job.kwargs,
}
func_name = job.func_name
except DeserializationError:
extra = {}
func_name = '<DeserializationError>'
# the properties below should be safe however
extra.update({'queue': job.origin, 'job_id': job.id})
# func_name
self.log.error(exc_string, exc_info=True, extra=extra)
self.log.error(f'[Job {job.id}]: exception raised while executing ({func_name})\n' + exc_string,
extra=extra)
for handler in self._exc_handlers:
self.log.debug('Invoking exception handler %s', handler)

Loading…
Cancel
Save