Skip to content

Comments

feat: Async Support with httpx 🔥 #149

Open
drish wants to merge 23 commits intomainfrom
async-support
Open

feat: Async Support with httpx 🔥 #149
drish wants to merge 23 commits intomainfrom
async-support

Conversation

@drish
Copy link
Collaborator

@drish drish commented Jun 16, 2025

Introduces async support using the httpx library.

  • Base extra_requires setup
  • Async requests module setup
  • Api Keys module
  • Audiences module
  • Broadcasts module
  • Contacts module
  • Domains module
  • Emails module
  • Batch Emails module

SDK async version

  1. Users will need to install the async version of the sdk (extra-requries) with: pip install resend[async]

  2. Set the default_http_client:

import resend
# Set up async HTTP client
resend.default_http_client = resend.HTTPXClient()
  1. call the async version method (suffixed with _async):
email: resend.Email = await resend.Emails.send_async(params)

@pedroimpulcetto
Copy link
Contributor

wow, I loved this Async support!!! great job @drish

Base automatically changed from feat/custom-http-client to main July 7, 2025 17:46
@drish drish marked this pull request as ready for review July 18, 2025 15:19
@ojh
Copy link

ojh commented Nov 19, 2025

@bukinoshita @felipevolpone Is there any update on this? Are there any outstanding tasks that any of us could potentially help with to get this PR unblocked and merged?

@drish
Copy link
Collaborator Author

drish commented Nov 21, 2025

@bukinoshita @felipevolpone Is there any update on this? Are there any outstanding tasks that any of us could potentially help with to get this PR unblocked and merged?

@ojh i had to re-prioritize some work and this ended up having to wait a bit. I'll be working on this back again this coming week, should be very close to wrap up.

@tchaguitos
Copy link

nice! i was thinking about this and now i am happy because this pull request. thanks

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

10 issues found across 23 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="resend/contacts/_contacts.py">

<violation number="1" location="resend/contacts/_contacts.py:379">
P2: Custom agent: **API Key Permission Check SDK Methods**

New async contact paths now call the global /contacts endpoints. Please confirm that production API keys have the required permissions for global contact operations to avoid permission-related failures after deployment (API Key Permission Check SDK Methods rule).</violation>
</file>

<file name="resend/emails/_attachments.py">

<violation number="1" location="resend/emails/_attachments.py:133">
P2: AsyncRequest can be undefined when async extras aren’t installed, causing a NameError on get_async. Import it inside the method (or raise a clear ImportError) to fail fast with a clear message.</violation>
</file>

<file name="tests/contacts_segments_async_test.py">

<violation number="1" location="tests/contacts_segments_async_test.py:8">
P2: Async test methods on a `unittest.TestCase` base are not awaited, so these tests won’t run and will report false positives. Use `IsolatedAsyncioTestCase` (or a pytest async marker) for async tests.</violation>
</file>

<file name="tests/contact_properties_async_test.py">

<violation number="1" location="tests/contact_properties_async_test.py:8">
P2: These async tests inherit from `unittest.TestCase` via `ResendBaseTest`, so the `async def` test methods are never awaited by the unittest runner. The assertions inside the new tests won’t execute. Use an async-capable base like `unittest.IsolatedAsyncioTestCase` or convert these to pytest-style async tests.</violation>
</file>

<file name="resend/webhooks/_webhooks.py">

<violation number="1" location="resend/webhooks/_webhooks.py:370">
P2: Async methods call `AsyncRequest` even when the optional async dependency isn’t installed, which will raise `NameError` at runtime. Add an explicit guard (and/or define `AsyncRequest = None` on import failure) to raise a clear ImportError before trying to use it.</violation>
</file>

<file name="tests/templates_async_test.py">

<violation number="1" location="tests/templates_async_test.py:8">
P2: Async test methods are defined on a `unittest.TestCase` subclass, which doesn’t await async tests. These tests will be skipped or treated as coroutines rather than executed. Use an async-aware base class (e.g., `unittest.IsolatedAsyncioTestCase`) or mark the tests for an async test runner (e.g., pytest with `@pytest.mark.asyncio`) and adjust the base class accordingly.</violation>
</file>

<file name="resend/contact_properties/_contact_properties.py">

<violation number="1" location="resend/contact_properties/_contact_properties.py:284">
P2: Guard async methods against missing `resend[async]` so callers get a clear ImportError instead of a NameError when AsyncRequest isn’t available.</violation>
</file>

<file name="resend/contacts/_topics.py">

<violation number="1" location="resend/contacts/_topics.py:217">
P2: AsyncRequest is optional but the ImportError is swallowed, leaving AsyncRequest undefined. Calling list_async/update_async without the async extra will raise a NameError instead of a clear ImportError. Add an explicit guard or error when the async dependency is missing.</violation>
</file>

<file name="resend/topics/_topics.py">

<violation number="1" location="resend/topics/_topics.py:251">
P2: `AsyncRequest` is silently ignored on ImportError, so calling any `*_async` method without the async extra raises `NameError` instead of a clear dependency error. Add a guard or explicit ImportError for missing async extras.</violation>
</file>

<file name="tests/webhooks_async_test.py">

<violation number="1" location="tests/webhooks_async_test.py:8">
P2: Async tests in a unittest.TestCase subclass won’t be awaited, so these new async tests won’t actually run (they’ll return coroutine objects and be treated as passing). Use an async-capable base (e.g., IsolatedAsyncioTestCase) or pytest-asyncio markers instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@drish drish requested review from gabrielmfern and removed request for bukinoshita and felipevolpone February 23, 2026 14:52
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.

4 participants