From da152f5bd89bc197dd11cf464c3c47d6aef9f5e1 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sat, 3 Jan 2026 21:03:57 +0000 Subject: [PATCH] Fix regression from prior changes that broke determinism again, simplify the code to avoid that happening again. --- randquik/workers.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/randquik/workers.py b/randquik/workers.py index be888cc..5ff5921 100644 --- a/randquik/workers.py +++ b/randquik/workers.py @@ -98,7 +98,6 @@ class _FdProducer: timer = stopwatch() try: - slot = -1 # No slot to commit on first iteration while True: # Claim next block number with self.lock_blkno: @@ -108,11 +107,6 @@ class _FdProducer: with self._lock: stats.lock_acquire_time += next(timer) - # Commit previous block (mark ready + notify consumer) - if slot >= 0: - self.ready[slot] = True - self.has_data.notify() - stats.lock_notify_time += next(timer) # Wait for the NEXT slot to be free slot = blkno % self.num_slots while self.ready[slot] and not self.quit: @@ -132,6 +126,11 @@ class _FdProducer: stats.blocks_processed += 1 stats.bytes_generated += self.block_size + # Commit block (mark ready + notify consumer) + with self._lock: + self.ready[slot] = True + self.has_data.notify() + finally: view.release() with self._stats_lock: