diff --git a/procrastinate/worker.py b/procrastinate/worker.py index 940d1254d..75c7f3c04 100644 --- a/procrastinate/worker.py +++ b/procrastinate/worker.py @@ -247,6 +247,7 @@ async def run_job(self, job: jobs.Job, worker_id: int) -> None: if retry_exception: log_title = "Error, to retry" log_action = "job_error_retry" + log_level = logging.INFO raise retry_exception from e raise exceptions.JobError() from e diff --git a/tests/unit/test_worker.py b/tests/unit/test_worker.py index a55521eff..cdb6cf847 100644 --- a/tests/unit/test_worker.py +++ b/tests/unit/test_worker.py @@ -245,7 +245,9 @@ def task(): assert all([name == record_worker_name for name in worker_names]) -async def test_run_job_error(app): +async def test_run_job_error(app, caplog): + caplog.set_level("INFO") + def job(a, b): # pylint: disable=unused-argument raise ValueError("nope") @@ -266,8 +268,21 @@ def job(a, b): # pylint: disable=unused-argument with pytest.raises(exceptions.JobError): await test_worker.run_job(job=job, worker_id=3) + assert ( + len( + [ + r + for r in caplog.records + if r.levelname == "ERROR" and "to retry" not in r.message + ] + ) + == 1 + ) + + +async def test_run_job_retry(app, caplog): + caplog.set_level("INFO") -async def test_run_job_retry(app): def job(a, b): # pylint: disable=unused-argument raise ValueError("nope") @@ -288,6 +303,18 @@ def job(a, b): # pylint: disable=unused-argument with pytest.raises(exceptions.JobRetry): await test_worker.run_job(job=job, worker_id=3) + assert ( + len( + [ + r + for r in caplog.records + if r.levelname == "INFO" and "to retry" in r.message + ] + ) + == 1 + ) + assert len([r for r in caplog.records if r.levelname == "ERROR"]) == 0 + async def test_run_job_not_found(app): job = jobs.Job(