Skip to content

Add asyncio support to the Python SDK#57

Open
kvz wants to merge 16 commits into
py310-v2from
asyncio-v2
Open

Add asyncio support to the Python SDK#57
kvz wants to merge 16 commits into
py310-v2from
asyncio-v2

Conversation

@kvz
Copy link
Copy Markdown
Member

@kvz kvz commented May 20, 2026

Why

Issue #9 asks for a Pythonic asyncio surface without changing sync callers. This PR adds a separate AsyncTransloadit API on top of the v2 runtime/security branch (#56) so async users can opt in without affecting the existing synchronous client.

What changed

  • Added transloadit.async_client.AsyncTransloadit with async versions of the existing client helpers.
  • Added async request/assembly/template helpers and a shared Response wrapper that works for both sync and async responses.
  • Added async context manager cleanup plus explicit aclose()/close().
  • Kept the sync Transloadit API untouched.

TUS/resumable tradeoff

  • Non-resumable uploads use aiohttp directly.
  • Resumable uploads still delegate to the existing tuspy uploader, but through asyncio.to_thread() so the event loop is not blocked. That keeps the implementation straightforward and honest about the sync TUS path.

Testing

  • Added high-level async tests for GET/list/cancel/template flows, non-resumable assembly upload, wait=True polling with mocked asyncio.sleep, async context-manager cleanup, and resumable upload delegation.
  • Verified locally with:
    • poetry check
    • poetry install
    • poetry run pytest tests
    • poetry run sphinx-build -E -b html docs/source docs/_build/html
    • poetry run tox -e py314
    • poetry build
    • bash -n scripts/test-in-docker.sh scripts/notify-registry.sh
    • git diff --check
    • ./scripts/test-in-docker.sh --python 3.12

This PR is intentionally based on #56 and targets base branch py310-v2.

@kvz kvz self-assigned this May 20, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 20, 2026

Codecov Report

❌ Patch coverage is 98.82904% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.52%. Comparing base (89a52c3) to head (7f8fc8c).

Files with missing lines Patch % Lines
transloadit/async_request.py 97.02% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           py310-v2      #57      +/-   ##
============================================
+ Coverage     86.60%   95.52%   +8.91%     
============================================
  Files             7       11       +4     
  Lines           209      625     +416     
  Branches         19       81      +62     
============================================
+ Hits            181      597     +416     
  Misses           28       28              
Flag Coverage Δ
unittests 95.52% <98.82%> (+8.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants