Skip to content

Generate sync clients from async ones to remove duplicated code #1080

Description

@vdusek

Sync and async clients are hand-maintained copies (~6,300 lines each side). Every change is made twice and the copies already drift (method order, formatting). Mechanically un-asyncing the async classes leaves only ~500 differing lines, mostly in code that is genuinely different: HTTP clients, StreamedLog, StatusMessageWatcher, RQ batch_add_requests.

Proposal: write async by hand, generate sync from it, commit both, and fail CI when they're out of sync. This is what httpcore, psycopg, pymongo and elasticsearch-py do. Tooling: unasync, unasyncd, or a small script in scripts/. The divergent parts listed above stay hand-written.

Alternatives are worse: sharing more logic in ResourceClientBase still duplicates signatures and docstrings, and wrapping async in an event loop for sync breaks inside running loops.

✍️ Drafted by Claude Code

Activity

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

    solutioningThe issue is not being implemented but only analyzed and planned.t-toolingIssues with this label are in the ownership of the tooling team.tech enhancementEnhancement of our tech stack.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions