Skip to content

Commit

Permalink
Merge pull request #96 from i-VRESSE/arq-returncode
Browse files Browse the repository at this point in the history
Raise exception when subprocess has return code != 0
  • Loading branch information
sverhoeven authored May 21, 2024
2 parents ca74e74 + 24a2952 commit 0cfb03d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/bartender/schedulers/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ async def _pool(self) -> ArqRedis:
return self.connection


class JobFailureError(Exception):
"""Error during job running."""


async def _exec( # noqa: WPS210
ctx: dict[Any, Any],
description: JobDescription,
Expand All @@ -142,7 +146,10 @@ async def _exec( # noqa: WPS210
)
returncode = await proc.wait()
(description.job_dir / "returncode").write_text(str(returncode))
# TODO raise exception when returncode != 0 ?
if returncode != 0:
raise JobFailureError(
f"Job failed with return code {returncode}",
)


def arq_worker(config: ArqSchedulerConfig, burst: bool = False) -> Worker:
Expand Down

0 comments on commit 0cfb03d

Please sign in to comment.