Skip to content

Commit f87401b

Browse files
committed
fix: run_job error return
1 parent d272a80 commit f87401b

File tree

1 file changed

+11
-11
lines changed
  • runpod/serverless/modules

1 file changed

+11
-11
lines changed

runpod/serverless/modules/job.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,31 @@ async def get_job(session):
3434

3535
def run_job(handler, job):
3636
'''
37-
run the handler and format the return
37+
Run the job using the handler.
38+
Returns the job output or error.
3839
'''
3940
log.info(f"Started working on {job['id']} at {time.time()} UTC")
4041

42+
run_result = {"error": "Failed to return job output or capture error."}
43+
4144
try:
4245
job_output = handler(job)
4346

4447
if "error" in job_output:
45-
return {
46-
"error": job_output['error']
47-
}
48-
49-
return {
50-
"output": job_output
51-
}
48+
run_result = {"error": job_output['error']}
49+
else:
50+
run_result = {"output": job_output}
5251

5352
except Exception as err: # pylint: disable=broad-except
5453
log.error(f"Error while running job {job['id']}: {err}")
5554

56-
return {
57-
"error": str(err)
58-
}
55+
run_result = {"error": str(err)}
5956

6057
finally:
6158
log.info(f"Finished working on {job['id']} at {time.time()} UTC")
59+
log.info(f"Run result: {run_result}")
60+
61+
return run_result # pylint: disable=lost-exception
6262

6363

6464
@retry(max_attempts=3, base_delay=1, max_delay=3)

0 commit comments

Comments
 (0)