Skip to content

Add Async support with AsyncClient and AsyncOauthClient #5#14

Open
Deadpool2000 wants to merge 1 commit intoopenapi:mainfrom
Deadpool2000:fix-issue-25-3-new
Open

Add Async support with AsyncClient and AsyncOauthClient #5#14
Deadpool2000 wants to merge 1 commit intoopenapi:mainfrom
Deadpool2000:fix-issue-25-3-new

Conversation

@Deadpool2000
Copy link
Copy Markdown
Contributor

This PR addresses the issue where the SDK was blocking the event loop in async frameworks like aiohttp or FastAPI. I've added full asynchronous support and improved resource management across the board.

What's new?

  • Async Clients: Introduced
  1. AsyncClient
  2. AsyncOauthClient . These use httpx.AsyncClient under the hood to handle non-blocking I/O.
  • Context Manager Support: All clients (both sync and async) now support context managers (with and async with). This ensures that the underlying connection pool is properly closed after use, preventing resource leaks.

  • Simplified Imports: You can now import clients directly from the package root: from openapi_python_sdk import Client, AsyncClient

  • Better Tests: Added a new test suite for the async implementation using IsolatedAsyncioTestCase (standard in Python 3.10+).

Quick Usage Example

from openapi_python_sdk import AsyncClient
async with AsyncClient(token="YOUR_TOKEN") as client:
    data = await client.request(
        method="GET",
        url="https://api.example.com/endpoint"
    )

Verification

  • Ran existing 10 sync tests (all passing).
  • Added 4 new async tests covering authentication and generic requests (all passing).
  • Total coverage: 14/14 tests passing.

Updated the README.md with these usage examples to help users get started.

Let me know if you have any feedback!

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