File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed
runpod/serverless/modules Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -77,15 +77,18 @@ async def get_job(
77
77
log .error (f"- Failed to get job, status code: { response .status } " )
78
78
return
79
79
80
- try :
81
- jobs = await response .json ()
82
- log .debug (f"- Job(s) Received" )
83
- except TypeError as err :
84
- log .debug (f"- { response } | { err } " )
85
- raise response
86
- except Exception as err :
87
- log .debug (f"- { response } | { err } " )
88
- raise err
80
+ # Verify if the content type is JSON
81
+ if response .content_type != "application/json" :
82
+ log .error (f"- Unexpected content type: { response .content_type } " )
83
+ return
84
+
85
+ # Check if there is a non-empty content to parse
86
+ if response .content_length == 0 :
87
+ log .debug ("- No content to parse." )
88
+ return
89
+
90
+ jobs = await response .json ()
91
+ log .debug (f"- Received Job(s)" )
89
92
90
93
# legacy job-take API
91
94
if isinstance (jobs , dict ):
Original file line number Diff line number Diff line change @@ -150,11 +150,14 @@ async def get_jobs(self, session: ClientSession):
150
150
acquired_jobs = await asyncio .wait_for (
151
151
get_job (session , jobs_needed ), timeout = 30
152
152
)
153
+ except asyncio .CancelledError :
154
+ log .debug ("JobScaler.get_jobs | Request was cancelled." )
155
+ continue
153
156
except TimeoutError :
154
157
log .debug ("JobScaler.get_jobs | Job acquisition timed out. Retrying." )
155
158
continue
156
159
except TypeError as error :
157
- log .debug (f"Unexpected error: { error } . acquired_jobs= { acquired_jobs } " )
160
+ log .debug (f"JobScaler.get_jobs | Unexpected error: { error } ." )
158
161
continue
159
162
except Exception as error :
160
163
log .error (
You can’t perform that action at this time.
0 commit comments