Fix async activation retry handling#2765
Merged
Merged
Conversation
Convert activation HTTP calls to aiohttp coroutines, await activation before retrying, and allocate independent protocol checkers per site check so concurrent retries do not overwrite shared checker state.
3c682a8 to
8f6347b
Compare
Owner
|
@fancyboi999 amazing work, thank you so much! π π π₯ I'm merging it β |
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.
Problem
Activation providers were still doing synchronous HTTP work from Maigret's async checking pipeline. When a response body matched an activation marker, the checker could block the event loop while refreshing provider tokens.
While verifying the async conversion through the CLI, I also found that the default protocol checkers were shared mutable instances. With concurrent activation retries, one site's retry could reuse another site's prepared URL/headers.
Closes #2671.
Root cause
ParsingActivatormethods usedrequestsdirectly.check_site_for_username()called activation withoutawait.process_site_result()had a second synchronous activation block that mutated headers but did not retry the current response.maigret()stored checker instances inoptions["checkers"], so concurrent site checks shared mutableurl,headers,method, andpayloadstate.Solution
async defand useaiohttp.ClientSession.process_site_result().Validation
Runtime verification through the real CLI with a temporary local Maigret DB and local HTTP server:
python -m maigret alice ... -n 301.845sprofile:two:alice:jwt token-twoprofile:one:alice:jwt token-oneprofile:three:alice:jwt token-threeProbe:
python -m maigret alice ... -n 103.832sAdditional local checks:
python -m pytest tests/test_activation.py tests/test_checking.py -q55 passed, 1 skippedpython -m pytest -q --ignore=tests/test_submit.py --ignore=tests/test_twitter.py294 passed, 3 skipped.githooks/pre-commituv tool install poetrydb_meta.jsontimestamp update with unchangeddata_sha256, so that unrelated timestamp churn is intentionally not included in this PRgit diff --checkKnown environment notes:
tests/test_submit.pyhas live Google Play / icq.com network dependencies in this environment.tests/test_twitter.pylive GraphQL probe currently returns HTTP 403.