File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
runpod/serverless/modules Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -34,31 +34,31 @@ async def get_job(session):
34
34
35
35
def run_job (handler , job ):
36
36
'''
37
- run the handler and format the return
37
+ Run the job using the handler.
38
+ Returns the job output or error.
38
39
'''
39
40
log .info (f"Started working on { job ['id' ]} at { time .time ()} UTC" )
40
41
42
+ run_result = {"error" : "Failed to return job output or capture error." }
43
+
41
44
try :
42
45
job_output = handler (job )
43
46
44
47
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 }
52
51
53
52
except Exception as err : # pylint: disable=broad-except
54
53
log .error (f"Error while running job { job ['id' ]} : { err } " )
55
54
56
- return {
57
- "error" : str (err )
58
- }
55
+ run_result = {"error" : str (err )}
59
56
60
57
finally :
61
58
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
62
62
63
63
64
64
@retry (max_attempts = 3 , base_delay = 1 , max_delay = 3 )
You can’t perform that action at this time.
0 commit comments