test: generalize integration polling helpers#920
Draft
vdusek wants to merge 1 commit into
Draft
Conversation
Make call_with_exp_backoff and poll_until_condition generic and consistent so the same two helpers can be shared across apify-sdk-python, crawlee-python and apify-client-python: - call_with_exp_backoff no longer takes rq_access_mode. It now takes an optional condition (default: truthy) and retries fn until the condition holds, returning the last result. The Apify RQ single/shared distinction moves to the call sites via max_retries (0 = call once / single mode, 5 = retry / shared mode). - poll_until_condition gains the same condition default and now accepts both sync and async callables (so it can poll plain values too). - Both helpers accept sync or async fn via a small _maybe_await helper, typed with overloads so the return type is preserved. All ~36 call sites in test_request_queue.py are refactored accordingly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #920 +/- ##
==========================================
- Coverage 87.00% 86.97% -0.04%
==========================================
Files 48 48
Lines 2956 2956
==========================================
- Hits 2572 2571 -1
- Misses 384 385 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generalizes the two integration-test polling helpers so the same pair can be shared across
apify-sdk-python,crawlee-python, andapify-client-python.call_with_exp_backoffno longer takesrq_access_mode. It now takes an optionalcondition(default: truthy) and retriesfnuntil the condition holds, returning the last result. The Apify RQ single/shared distinction moves to the call sites viamax_retries(0= call once / single mode,5= retry / shared mode).poll_until_conditiongains the sameconditiondefault and now accepts both sync and async callables.fnvia a small_maybe_awaithelper, typed with overloads so the return type is preserved.All ~36 call sites in
test_request_queue.pyare refactored accordingly. Lint, type-check, and test collection pass; integration tests require a platform token and were not run locally.