Skip to content

Commit 773e80b

Browse files
committed
Fix issue where exceptions where unpickling exceptions were not being stored properly
1 parent f4f66ef commit 773e80b

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

gridmap/job.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self, f, args, kwlist=None, cleanup=True, mem_free="1G",
140140
self.track_mem = []
141141
self.track_cpu = []
142142
self.heart_beat = None
143-
self.exception = None
143+
self.traceback = None
144144
self.host_name = ''
145145
self.timestamp = None
146146
self.log_stdout_fn = ''
@@ -225,6 +225,7 @@ def execute(self):
225225
self.ret = self.function(*self.args, **self.kwlist)
226226
except Exception as exception:
227227
self.ret = exception
228+
self.traceback = traceback.format_exc()
228229
traceback.print_exc()
229230
del self.args
230231
del self.kwlist
@@ -335,11 +336,16 @@ def check(self, session_id, jobs):
335336
if msg["command"] == "store_output":
336337
# be nice
337338
return_msg = "thanks"
339+
338340
# store tmp job object
339-
tmp_job = msg["data"]
340-
# copy relevant fields
341-
job.ret = tmp_job.ret
342-
job.exception = tmp_job.exception
341+
if isinstance(msg["data"], Job):
342+
tmp_job = msg["data"]
343+
# copy relevant fields
344+
job.ret = tmp_job.ret
345+
job.traceback = tmp_job.traceback
346+
# Return an exception instead of a job, so store that
347+
else:
348+
job.ret = msg["data"]
343349
# is assigned in submission process and not written back
344350
# server-side
345351
job.timestamp = datetime.now()
@@ -488,7 +494,7 @@ def send_error_mail(job):
488494

489495
if isinstance(job.ret, Exception):
490496
body_text += "job encountered exception: {}\n".format(job.ret)
491-
body_text += "stacktrace: {}\n\n".format(job.exception)
497+
body_text += "stacktrace: {}\n\n".format(job.traceback)
492498

493499
logger.info('Email body: %s', body_text)
494500

0 commit comments

Comments
 (0)