Skip to content

Add asyncio support to the Python SDK#57

Draft
kvz wants to merge 22 commits into
py310-v2from
asyncio-v2
Draft

Add asyncio support to the Python SDK#57
kvz wants to merge 22 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 97.22222% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.55%. Comparing base (89a52c3) to head (bb04389).

Files with missing lines Patch % Lines
transloadit/async_request.py 95.67% 7 Missing ⚠️
transloadit/api_url.py 92.85% 2 Missing ⚠️
transloadit/assembly.py 86.66% 2 Missing ⚠️
transloadit/response.py 93.93% 2 Missing ⚠️
transloadit/async_assembly.py 99.28% 1 Missing ⚠️
transloadit/request.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           py310-v2      #57      +/-   ##
============================================
+ Coverage     86.60%   95.55%   +8.95%     
============================================
  Files             7       14       +7     
  Lines           209      698     +489     
  Branches         19       94      +75     
============================================
+ Hits            181      667     +486     
- Misses           28       31       +3     
Flag Coverage Δ
unittests 95.55% <97.22%> (+8.95%) ⬆️

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.

@kvz
Copy link
Copy Markdown
Member Author

kvz commented May 21, 2026

Setting this back to draft while we expand the feature scope: the v2 PR should also cover the full Transloadit API endpoint surface before we treat it as ready. I added a matching @todo to the 2.0.0 CHANGELOG section so the release notes get updated once the endpoint coverage is complete.

@kvz kvz marked this pull request as draft May 21, 2026 14:07
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