Skip to content

Make the Python SDK fully async on httpx2 - #173

Closed
Xharry01X wants to merge 11 commits into
appwrite:mainfrom
Xharry01X:main
Closed

Xharry01X wants to merge 11 commits into
appwrite:mainfrom
Xharry01X:main

Conversation

@Xharry01X

Copy link
Copy Markdown

What does this PR do?

Migrates the Python SDK from the synchronous requests client to a fully asynchronous implementation built on httpx2 and anyio. All service methods now return coroutines that must be awaited, Client exposes aclose() / async context manager usage, and the underlying connection pool is closed explicitly. Includes thread-safe deprecation warning filters, redirect support for location responses, sibling chunk cleanup on partial upload failures, and refreshed README examples for the async API.

Test Plan?

Ran the full suite with python -m unittest discover -s test -t . — 1008 tests, all passing, with both invocation styles (-s test -t . and from inside test/) verified so the httpx2/respx transport aliasing is active regardless of how tests are started. Also re-ran with HTTPS_PROXY/HTTP_PROXY pointed at a dead address to confirm no test escapes to the network, and compiled every Python block in README.md to confirm the examples are valid, runnable scripts.
Related PRs and Issues?

None.

Have you read the Contributing Guidelines?

Yes.

Use return_exceptions with asyncio.gather so a failed chunk's
error is not raised while other chunk uploads are still in
flight.
Replaces asyncio.gather/to_thread with anyio task groups and
to_thread.run_sync. Retired HTTP clients are now closed in aclose()
since anyio has no fire-and-forget tasks. Adds anyio dependency.
Emit warnings in a scoped context so caller filters are preserved. Add
tests
for sync and async decorators, warning attribution, and filter
restoration.
Require all service methods, Client.call, and Client.chunked_upload to
be
awaited. Coroutine on_progress callbacks are also awaited.

The SDK now requires Python 3.11 and uses httpx2 instead of requests.
Client.aclose() and async context manager support are also documented.
Alias httpx to httpx2 before importing respx for root, service, and
standalone test discovery.

Treat falsey Appwrite Cloud error codes as unreachable responses.
@hansi-codes

hansi-codes Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The README error-handling example references a users variable that is local to an earlier function and raises NameError when run.

This PR migrates the Python SDK transport and service APIs to asynchronous httpx2/anyio, adds explicit client-pool lifecycle management, and updates chunked uploads for async progress callbacks. It also updates tests, package metadata, and documentation for the async API and Python 3.11+ requirement.

59 of 76 changed files were too large to include in full.

Verdict New comments Fixed Still open
💬 Commented 1 0 0

Note

@Xharry01X does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

Finding Where
🟡 The error example references an out-of-scope variable README.md:139
Fix with agent prompt
### Issue 1
README.md:139
**The error example references an out-of-scope variable**

In the preceding request example, `users` is created inside `main()`, so it is not visible to this separate `main`; running this error-handling block raises `NameError` before making a request. Create a `Users(client)` instance in this example or define it in a shared scope.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
📂 Walkthrough · 7
File Change
appwrite/client.py Replaced synchronous requests with an async HTTP client, explicit pool cleanup, redirect handling, and async chunked uploads.
appwrite/services/** Converted service API methods to coroutines and awaited transport and upload calls.
appwrite/utils/deprecated.py Added async-aware deprecation handling and synchronized temporary warning filters.
test/** Updated service tests for async execution and added coverage for client lifecycle, uploads, and redirects.
README.md, CHANGELOG.md Documented the async API, client cleanup, and associated breaking changes.
requirements.txt, setup.py, pyproject.toml Updated runtime and test dependencies and raised the supported Python version to 3.11.
.gitignore Added Python build, environment, cache, and editor exclusions.

Reviewed 5d32742 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@github-actions

Copy link
Copy Markdown

This library is auto-generated by the Appwrite SDK Generator, and does not accept pull requests directly. To learn more about how you can help us improve this SDK, please check the contributing guide.

@github-actions github-actions Bot closed this Oct 26, 2026

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread README.md

async def main():
try:
user = await users.get(user_id='<USER_ID>')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The error example references an out-of-scope variable

In the preceding request example, users is created inside main(), so it is not visible to this separate main; running this error-handling block raises NameError before making a request. Create a Users(client) instance in this example or define it in a shared scope.

Prompt To Fix With AI
This is a comment left during a code review.
Path: README.md
Line: 139

Comment:
**The error example references an out-of-scope variable**

In the preceding request example, `users` is created inside `main()`, so it is not visible to this separate `main`; running this error-handling block raises `NameError` before making a request. Create a `Users(client)` instance in this example or define it in a shared scope.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · documentation · Reply if this doesn't apply.

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.

1 participant