Skip to content

Commit 63942ff

Browse files
committed
attempt to fix race condition
1 parent 6ad4320 commit 63942ff

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/gradient_free_optimizers/search.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,14 @@ def _submit_one():
314314
if self._check_stop(n_evaluated):
315315
break
316316

317-
# Refill the freed worker slot
318-
_submit_one()
317+
# Refill the freed worker slot. Cache hits consume iterations
318+
# without adding futures, so keep trying until a future is
319+
# queued or there's nothing left to submit.
320+
while n_evaluated < n_iter:
321+
if _submit_one() == 0:
322+
break
323+
if self._check_stop(n_evaluated):
324+
break
319325

320326
def _run_batch_async(self, n_iter, nth_trial):
321327
"""Batch-async iteration for stateful optimizers.

0 commit comments

Comments
 (0)