Code Room
Code reviewHardcr-g611
Subject Storage raceLevel Senior–Staff~22 minCommon in Storage & CDN · Concurrency interviewsIndustries Software development, Technology

Question

Review this Python counter persisted to a shared file.

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
import json, os COUNTER_FILE = "/var/lib/app/counter.json" def increment_counter():    if os.path.exists(COUNTER_FILE):        with open(COUNTER_FILE) as f:            state = json.load(f)    else:        state = {"count": 0}    state["count"] += 1    with open(COUNTER_FILE, "w") as f:        json.dump(state, f)    return state["count"]
Run or narrate your approach, then ask the coach.