Back to browse
GitHub Repository

Python library for controlling ordering of concurrent events to find and reproduce race conditions

3 starsPython

Python Concurrency Testing with Frontrun

by lucaswiman·Aug 6, 2026·1 point·1 comment

AI Analysis

●●●BangerWizardryBig BrainNiche Gem

Rust-powered DPOR engine finds Python race conditions without code changes or sleep() hacks.

Strengths
  • Bytecode-level DPOR engine in Rust prunes interleavings efficiently.
  • Detects races across abstraction boundaries like SQL locks and thread locks.
  • Generates deterministic, replayable counterexamples with causal traces.
Weaknesses
  • Free-threading transition niche may limit immediate mainstream adoption.
  • Complex concurrency bugs still require deep understanding to fix.
Target Audience

Python library authors and backend engineers

Similar To

loom · pytest · ThreadSanitizer

Post Description

Hi HN, I'm the author of Frontrun, a Python concurrency testing library I built over the past 6 months using Claude Code and Codex. It uses bytecode tracing and various forms of monkeypatching to schedule across threads, async and multiprocessing allowing you to find and deterministically reproduce race conditions or deadlocks.

It can understand Python variable assignments, SQL statements and Redis commands, which can detect races that cross abstraction boundaries, e.g. a deadlock between threading.Lock() in one thread and a SQL row lock in another.

To use it, do `pip install frontrun`[1] then put the following in a pytest case:

result = frontrun.explore( setup=Counter, workers=Counter.increment, count=2, ) result.assert_holds()

Then use `frontrun pytest path/to/test_counter.py`.

My hope is that this will allow authors of libraries which are not currently threadsafe to weather the freethreading transition more easily or to raise the bar for issue submissions involving race conditions. I've put a lot of work into making races deterministic and making the error trace interpretable, demonstrating why that sequence of events that triggers the race. I'd love any usability feedback or success/failure stories you have, and I'm happy to answer any questions about how it works.

[1] MacOS and Linux only.

Similar Projects