test: deflake stress_10k on loaded runners
Drop may discard queued work after setting shutdown, so on a slow CI runner (observed: macos-latest) it can win the race before any worker completes a single job, failing the count > 0 assert. Wait (bounded, 10s) for one completion before initiating shutdown — the no-hang property under test is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
acc91fafae
commit
c3925858fb
|
|
@ -494,6 +494,18 @@ mod tests {
|
|||
}
|
||||
handles.push(h);
|
||||
}
|
||||
// Drop may discard still-queued work after setting shutdown,
|
||||
// so on a loaded CI runner it can win the race before any
|
||||
// worker finishes even one job, flaking the `count > 0`
|
||||
// assert below (observed on the macOS runner). ~2/3 of the
|
||||
// queue is non-cancelled, so one completion must land unless
|
||||
// workers are wedged — wait for it, bounded.
|
||||
let wait_start = std::time::Instant::now();
|
||||
while completed.load(Ordering::Relaxed) == 0
|
||||
&& wait_start.elapsed() < std::time::Duration::from_secs(10)
|
||||
{
|
||||
std::thread::yield_now();
|
||||
}
|
||||
// Drain shutdown synchronously via Drop: this returns only
|
||||
// after every queued, non-cancelled job has run (or every
|
||||
// cancelled job has either run-then-noop or been silently
|
||||
|
|
|
|||
Loading…
Reference in New Issue