code
Mar 17, 2026EVAL-20260317-020251This distributed lock implementation has a subtle race condition that can cause two processes to hold the lock simultaneously. Find the bug and fix it. ```python import redis import time import uuid class DistributedLock: def __init__(self, redis_client, lock_name, timeout=10): self.redis = redis_client self.lock_name = f"lock:{lock_name}" self.timeout = timeout self.token = str(uuid.uuid4()) def acquire(self): while True: if self.redis.setnx(self.lock_name, self.token): self.redis.expire(self.lock_name, self.timeout) return True time.sleep(0.1) def release(self): if self.redis.get(self.lock_name) == self.token: self.redis.delete(self.lock_name) ``` Explain why this is dangerous in production and provide a correct implementation.
Winner
Qwen 3.5 397B-A17B
openrouter
9.74
WINNER SCORE
matrix avg: 9.14
10×10 Judgment Matrix · 43 judgments
OPEN DATA
| Judge ↓ / Respondent → | Qwen 3.5 9B | Qwen 3 8B | Qwen 3 32B | Qwen 3 Coder Next | Qwen 3.5 35B-A3B | Qwen 3.5 27B | Qwen 3.5 122B-A10B | Qwen 3.5 397B-A17B |
|---|---|---|---|---|---|---|---|---|
| Qwen 3.5 9B | — | 9.8 | · | · | 8.8 | 8.8 | 9.0 | 9.6 |
| Qwen 3 8B | 9.2 | — | · | 9.8 | 10.0 | 10.0 | 10.0 | 10.0 |
| Qwen 3 32B | 8.3 | 10.0 | — | 10.0 | 10.0 | 10.0 | 10.0 | 8.8 |
| Qwen 3 Coder Next | 9.0 | 10.0 | · | — | 10.0 | 10.0 | 10.0 | 10.0 |
| Qwen 3.5 35B-A3B | 6.3 | · | · | 8.6 | — | 8.2 | 9.0 | 10.0 |
| Qwen 3.5 27B | · | · | · | 8.6 | 7.9 | — | 8.8 | 9.8 |
| Qwen 3.5 122B-A10B | 6.3 | 8.6 | · | 8.8 | 8.2 | 8.6 | — | 10.0 |
| Qwen 3.5 397B-A17B | · | 9.8 | · | · | 6.7 | 9.8 | 9.6 | — |