Skip to content

Commit 5d1cec6

Browse files
authored
fix: sls-core-error (#364)
1 parent b148e14 commit 5d1cec6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

runpod/serverless/core.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def notregistered():
4141
"""Function to raise NotImplementedError"""
4242
raise RuntimeError("This function is not registered with the SLS Core.")
4343

44+
class SlsCoreError(Exception):
45+
pass
4446

4547
class Hook: # pylint: disable=too-many-instance-attributes
4648
"""Singleton class for interacting with sls_core.so"""
@@ -161,9 +163,9 @@ def get_jobs(self, max_concurrency: int, max_jobs: int) -> List[Dict[str, Any]]:
161163
b = "<failed to decode buffer>"
162164
if b == "":
163165
b = "<unknown error or buffer too small>"
164-
raise ValueError(f"_runpod_sls_get_jobs: status code 2: error from server: {b}")
166+
raise SlsCoreError(f"_runpod_sls_get_jobs: status code 2: error from server: {b}")
165167
elif code == ERROR_BUFFER_TOO_SMALL: # buffer too small
166-
raise ValueError("_runpod_sls_get_jobs: status code 3: buffer too small")
168+
raise SlsCoreError("_runpod_sls_get_jobs: status code 3: buffer too small")
167169
else:
168170
raise ValueError(f"_runpod_sls_get_jobs: unknown status code {code}")
169171

@@ -236,7 +238,7 @@ async def _process_job(
236238
aggregated_output: dict[str, typing.Any] = {"output": []}
237239

238240
async for part in generator_output:
239-
log.debug(f"SLS Core | Streaming output: {part}", job["id"])
241+
log.trace(f"SLS Core | Streaming output: {part}", job["id"])
240242

241243
if "error" in part:
242244
aggregated_output = part
@@ -282,7 +284,7 @@ async def run(config: Dict[str, Any]) -> None:
282284
while True:
283285
try:
284286
jobs = serverless_hook.get_jobs(max_concurrency, max_jobs)
285-
except RuntimeError as err:
287+
except SlsCoreError as err:
286288
log.error(f"SLS Core | Error getting jobs: {err}")
287289
await asyncio.sleep(0.2) # sleep for a bit before trying again
288290
continue

0 commit comments

Comments
 (0)