test: fix flaky `test_request_queue_unlock_requests` (#786)
## Summary Fix [this flaky CI run](https://github.com/apify/apify-client-python/actions/runs/25495772865/job/74814967391?pr=742) of `test_request_queue_unlock_requests[sync]`, which failed with `assert 2 == 3` on `unlock_response.unlocked_count`. **Root cause:** the polling loop called `list_and_lock_head` repeatedly, which has the side effect of locking items. Across multiple iterations (due to eventual consistency on `add_request`) the total set of actually-locked requests no longer matched the last response's `items` count, so `unlock_requests` could report a different count than the test expected. **Fix:** separate the two concerns — poll the read-only `list_head` until all 5 added requests are visible, then call `list_and_lock_head(limit=3)` exactly once. This removes the cross-iteration locking ambiguity. Applied the same treatment to `test_request_queue_list_and_lock_head`, which shared the same racy polling pattern.
V
Vlada Dusek committed
d1bd5a3a8f2b6fe943d9b1d8e0c92a59c1d001e5
Parent: a2fed29
Committed by GitHub <noreply@github.com>
on 5/12/2026, 9:50:56 AM