Skip to content

Remove sync/async client duplication: sans-I/O retry core #246

Closed

Description

@MarTrepodi

Component

SwgohComlink / SwgohComlinkAsync (clients)

Problem or Use Case

swgoh_comlink.py and swgoh_comlink_async.py are 641 lines each and maintained by hand, and they have already drifted apart:

The retry and pacing loop in _request is the hardest part to keep identical, and it is fully duplicated.

Proposed Solution

Move the decision logic out of _request into _base.py or retry.py, with no I/O:

  • Preparing a request: body, headers, and which httpx client to use.
  • Interpreting a response: turning an httpx.Response into a result or an exception.
  • The retry step: given an error and the attempt number, return the delay and whether a rate hold applies.

Each client keeps only a short loop that sends, sleeps, and handles cancellation for its runtime. Add a test that every public method on SwgohComlinkAsync exists on SwgohComlink with the same signature, aliases included.

Acceptance

  • _request in each client is under 40 lines and contains no retry decisions.
  • test_retry.py, test_retry_mocked.py, test_rate_hold_admission.py and test_pacer_scaling.py pass unchanged.
  • The method-signature parity test passes.

Alternatives Considered

  • Generate the sync client from the async one (unasync or a script), with a CI check. Deferred: it adds a dev dependency and a code-generation step. It can be revisited after this lands.

Activity

  1. added
    code maintenance
    on Nov 7, 2026
  2. github-actions commented on Nov 7, 2026

    @github-actions
    Contributor

    Addressed by #258, which is now merged into develop. This issue will close automatically when that change is released to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code maintenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions