Skip to content

Commit 0da81ae

Browse files
committed
Save our backtraces in a compatible manner with resque.
1 parent aaa3099 commit 0da81ae

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

pyres/failure/base.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,36 @@
44
class BaseBackend(object):
55
"""Provides a base class that custom backends can subclass. Also provides basic
66
traceback and message parsing.
7-
7+
88
The ``__init__`` takes these keyword arguments:
9-
9+
1010
``exp`` -- The exception generated by your failure.
11-
11+
1212
``queue`` -- The queue in which the ``Job`` was enqueued when it failed.
13-
13+
1414
``payload`` -- The payload that was passed to the ``Job``.
15-
15+
1616
``worker`` -- The worker that was processing the ``Job`` when it failed.
17-
17+
1818
"""
1919
def __init__(self, exp, queue, payload, worker=None):
2020
excc, _, tb = sys.exc_info()
21-
21+
2222
self._exception = excc
2323
self._traceback = traceback.format_exc()
2424
self._worker = worker
2525
self._queue = queue
2626
self._payload = payload
27-
28-
27+
28+
2929
def _parse_traceback(self, trace):
3030
"""Return the given traceback string formatted for a notification."""
31-
return trace
32-
31+
if not trace:
32+
return []
33+
34+
return trace.split('\n')
35+
3336
def _parse_message(self, exc):
3437
"""Return a message for a notification from the given exception."""
3538
return '%s: %s' % (exc.__class__.__name__, str(exc))
36-
39+

0 commit comments

Comments
 (0)