fix: a crashed job's crash line carries its job id
The bind sat inside the try, so it was already reset when the crash line and the cleanup were logged — the one line most worth finding by job id had none.
This commit is contained in:
@@ -493,14 +493,16 @@ def _worker_loop(idx: int) -> None:
|
||||
if job_id is None:
|
||||
_stop.wait(settings.download_poll_seconds)
|
||||
continue
|
||||
try:
|
||||
# Tag every line this job produces (including the crash below) with the job id: a worker
|
||||
# runs N jobs at once on N threads, so without it the interleaved output is unreadable.
|
||||
with logs.bind(job_id=job_id):
|
||||
# Tag every line this job produces (including the crash below) with the job id: a worker runs
|
||||
# N jobs at once on N threads, so without it the interleaved output is unreadable. The bind
|
||||
# wraps the handler too — bound inside the `try`, it was already reset by the time the crash
|
||||
# line was logged.
|
||||
with logs.bind(job_id=job_id):
|
||||
try:
|
||||
_process_job(job_id)
|
||||
except Exception: # noqa: BLE001
|
||||
log.exception("processing job %s crashed", job_id)
|
||||
_fail_running(job_id, error="Worker error", error_code=None)
|
||||
except Exception: # noqa: BLE001
|
||||
log.exception("processing job %s crashed", job_id)
|
||||
_fail_running(job_id, error="Worker error", error_code=None)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Reference in New Issue
Block a user