Skip to content

Fully converted synchronous to asynchronous - #171

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

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

Conversation

@Xharry01X

Copy link
Copy Markdown

What does this PR do?

Migrates the Python SDK from a synchronous requests client to a fully asynchronous httpx2 client, and moves the SDK's concurrency primitives from asyncio to anyio.

This is a breaking change. Every service method is now a coroutine and must be awaited.

Async client

Client now owns a pooled httpx2.AsyncClient instead of issuing per-call requests requests. It supports both an explicit shutdown and the async context manager protocol:

await client.aclose()

async with Client() as client:
    ...

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.
@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.

@hansi-codes

hansi-codes Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

🟡 Tier B · Needs changes before merging

The OAuth redirect flow now fails on 3xx responses, with additional minor warning-filter and README example issues to address.

This PR replaces the SDK’s synchronous HTTP transport with a pooled async client and converts generated service methods and chunked uploads to async. It also updates packaging metadata, documentation, and tests for asynchronous usage.

56 of 73 changed files were too large to include in full.

Verdict New comments Fixed Still open
🛑 Changes requested 3 0 0
Finding Where
🟠 Allow 3xx responses for location requests appwrite/client.py:225
🟡 Keep the warning filter change out of the awaited request appwrite/utils/deprecated.py:37
🟡 Run the async rows example's main function README.md:98
Fix with agent prompt
### Issue 1
appwrite/client.py:225
**Allow 3xx responses for location requests**

With redirects disabled for `response_type='location'`, `httpx2.Response.raise_for_status()` raises on 3xx responses before the `Location` header is returned. `Account.create_o_auth2_token` relies on this redirect response, so OAuth login now raises `AppwriteException` instead of returning the redirect URL.

### Issue 2
appwrite/utils/deprecated.py:37
**Keep the warning filter change out of the awaited request**

`warnings.filters` is process-global, and this `await` keeps the temporary `always` filter active for the entire API request before the `finally` resets it to `default`. During that time unrelated warnings in other tasks or threads bypass callers’ configured filters, and the reset overwrites any custom filters.

### Issue 3
README.md:98
**Run the async rows example's main function**

This example defines `main()` but never invokes it, so copying the snippet performs neither the row creation nor the list request. Unlike the earlier async example, it is missing an `asyncio.run(main())` call.

---

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 Adds the pooled async HTTP client, lifecycle management, and async chunked uploads.
appwrite/services/** Converts generated service calls to coroutines that await the client.
appwrite/utils/deprecated.py Adds coroutine-aware deprecation wrapping.
README.md Updates usage examples and documents async client cleanup.
setup.py, pyproject.toml, requirements.txt Updates Python and async transport dependencies.
test/** Migrates service tests and adds async transport, upload, and integration coverage.
.gitignore Ignores Python build, cache, and editor artifacts.

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

@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 B · 1 blocking finding to address. Summary

Comment thread appwrite/client.py
Comment thread appwrite/utils/deprecated.py
Comment thread README.md
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