Skip to content

Fix async activation retry handling#2765

Merged
soxoj merged 1 commit into
soxoj:mainfrom
fancyboi999:fix/2671-async-activation
Jun 13, 2026
Merged

Fix async activation retry handling#2765
soxoj merged 1 commit into
soxoj:mainfrom
fancyboi999:fix/2671-async-activation

Conversation

@fancyboi999

@fancyboi999 fancyboi999 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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

  • ParsingActivator methods used requests directly.
  • check_site_for_username() called activation without await.
  • process_site_result() had a second synchronous activation block that mutated headers but did not retry the current response.
  • maigret() stored checker instances in options["checkers"], so concurrent site checks shared mutable url, headers, method, and payload state.

Solution

  • Convert activation methods to async def and use aiohttp.ClientSession.
  • Await activation before retrying the site check.
  • Remove the duplicate activation block from process_site_result().
  • Store protocol checker factories instead of shared checker instances, so each site check gets independent request state.
  • Add regression coverage for async activation and concurrent retry isolation.

Validation

Runtime verification through the real CLI with a temporary local Maigret DB and local HTTP server:

  • python -m maigret alice ... -n 3
    • exit code: 0
    • elapsed: 1.845s
    • three 1-second activation requests started together and ended together
    • retries returned to their own profile URLs:
      • profile:two:alice:jwt token-two
      • profile:one:alice:jwt token-one
      • profile:three:alice:jwt token-three

Probe:

  • python -m maigret alice ... -n 1
    • exit code: 0
    • elapsed: 3.832s
    • activations were serialized and each retry used the matching profile URL.

Additional local checks:

  • python -m pytest tests/test_activation.py tests/test_checking.py -q
    • 55 passed, 1 skipped
  • python -m pytest -q --ignore=tests/test_submit.py --ignore=tests/test_twitter.py
    • 294 passed, 3 skipped
  • .githooks/pre-commit
    • completed after installing Poetry via uv tool install poetry
    • generated only a db_meta.json timestamp update with unchanged data_sha256, so that unrelated timestamp churn is intentionally not included in this PR
  • git diff --check
    • passed

Known environment notes:

  • tests/test_submit.py has live Google Play / icq.com network dependencies in this environment.
  • tests/test_twitter.py live GraphQL probe currently returns HTTP 403.

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.
@fancyboi999 fancyboi999 force-pushed the fix/2671-async-activation branch from 3c682a8 to 8f6347b Compare June 12, 2026 10:14
@soxoj

soxoj commented Jun 13, 2026

Copy link
Copy Markdown
Owner

@fancyboi999 amazing work, thank you so much! πŸš€ πŸ‘ πŸ”₯
Please, contribute more! ^_^

I'm merging it βœ…

@soxoj soxoj merged commit 13f43b3 into soxoj:main Jun 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Activation methods are called synchronously inside the async pipeline

2 participants