Code Room
Code reviewHardcr-g096
Subject Timeout handlingLevel Senior–Staff~30 minCommon in Concurrency interviewsIndustries Software development

Question

Review this Python distributed-lock usage (Redis SETNX-style).

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewpython
def process_job(job_id):    lock = redis.set(f"lock:{job_id}", "1", nx=True)    if not lock:        return    try:        do_work(job_id)    finally:        redis.delete(f"lock:{job_id}")
Run or narrate your approach, then ask the coach.