Skip to content

feat(api)!: migrate to asyncio - #1957

Draft
Fizzadar wants to merge 4 commits into
3.xfrom
v4/asyncio-test
Draft

Fizzadar wants to merge 4 commits into
3.xfrom
v4/asyncio-test

Conversation

@Fizzadar

Copy link
Copy Markdown
Member

For rebasing, each commit builds on the other. First commit is the real change everything else builds off it. Most exciting is 13a0a9c which replaces paramiko w/asyncssh!

@wowi42 wowi42 added API API mode specific issues. connectors Connector issues - builtin integrations with other tools. operations Issues with operations. CLI CLI mode specific issues. labels Sep 11, 2026
@Fizzadar Fizzadar changed the title V4/asyncio test feat(api)!: migrate to asyncio Sep 17, 2026
@Fizzadar
Fizzadar force-pushed the v4/asyncio-test branch 3 times, most recently from a5f68de to da9b3f8 Compare September 21, 2026 20:01

@wowi42 wowi42 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a large migration, and the current head has a host key handling issue and merge conflicts. It needs to be split and rebased before another review.

Issues

  • src/pyinfra/connectors/ssh.py:275-311 applies ssh_connect_kwargs and then replaces known_hosts and client_factory. src/pyinfra/connectors/ssh_hostkeys.py:32-51 maps valid AsyncSSH values such as in-memory bytes, callables, and loaded host key data to the default known hosts path. For example, ssh_connect_kwargs={"known_hosts": pinned_bytes} silently drops pinned_bytes. With accept-new, pyinfra can then trust and save a different key. Preserve these overrides or reject unsupported values, and add coverage for them.
  • The PR conflicts with 3.x: GitHub reports mergeable=CONFLICTING and mergeStateStatus=DIRTY. Rebase and rerun CI before merge.
  • uv.lock is included with unrelated lock regeneration and dependency removals. Drop the lockfile update from this PR.
  • pyproject.toml:24-25 adds greenlet>=3 and asyncssh[bcrypt]>=2.21 without upper bounds. Add major version upper bounds.
  • The scope is not atomic. The 58-file change combines the public API migration, CLI rewrite, AsyncSSH migration, and the async reboot operation. Split the core and CLI migration from the SSH library replacement.

Notes

  • Open PR #1482 covers the same asyncio and AsyncSSH migration. Mark it as superseded or explain how the two PRs relate.
  • The PR body has no test plan or AI-use disclosure.

Done at PyCon FR.

This migrates the public pyinfra API to asyncio. Operations and callbacks
may now be either sync or async functions and context is maintained using
greenlets (not gevent).

Also sets up support for parallel deploys as state/inventory now become
local context vars.

This branch has not been deployed

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

Labels

API API mode specific issues. CLI CLI mode specific issues. connectors Connector issues - builtin integrations with other tools. operations Issues with operations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants