Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise exception when subprocess has return code != 0 #96

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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