Skip to content

Commit 275095b

Browse files
committed
Add asyncio client support
1 parent 89a52c3 commit 275095b

12 files changed

Lines changed: 850 additions & 5 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### 2.0.0 / 2026-05-20 ###
22
* **Breaking Change**: Raised the supported Python runtime floor from 3.9+ to 3.12+ so the SDK no longer has to retain vulnerable locked dependency versions for EOL Python 3.9 or depend on tooling lines that are already dropping older runtime support.
3+
* Added explicit asyncio support with `AsyncTransloadit`, async request/assembly/template helpers, and `asyncio.sleep`-based polling. Resumable uploads stay on the existing TUS client, but run through `asyncio.to_thread()` so the event loop remains responsive instead of pretending the sync uploader is natively async.
34
* Raised the runtime HTTP stack to patched versions by requiring `requests` 2.33+ and adding an explicit `urllib3` 2.7+ floor.
45
* Updated development and documentation tooling, including `pytest` 9.0.3, `Sphinx` 9.1, `sphinx-autobuild` 2025.8, `coverage` 7.14, `tox` 4.54, and `requests-mock` 1.12.
56
* Updated CI and local Docker test coverage to a representative Python 3.12, 3.13, and 3.14 matrix.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ print(assembly_response.data.get('assembly_id'))
3636
print(assembly_response.data['assembly_id'])
3737
```
3838

39+
## Async usage
40+
41+
```python
42+
from transloadit.async_client import AsyncTransloadit
43+
44+
async with AsyncTransloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET") as tl:
45+
response = await tl.get_assembly(assembly_id="abc")
46+
print(response.data["ok"])
47+
48+
assembly = tl.new_assembly()
49+
assembly.add_step("resize", "/image/resize", {"width": 70, "height": 70})
50+
with open("PATH/TO/FILE.jpg", "rb") as upload:
51+
assembly.add_file(upload)
52+
response = await assembly.create(wait=True, resumable=False)
53+
```
54+
55+
The async client keeps polling on `asyncio.sleep`. Resumable uploads still use the existing TUS client, but are offloaded with `asyncio.to_thread()` so the event loop stays responsive.
56+
57+
If you do not use `async with`, call `await tl.aclose()` when you are done with the session.
58+
3959
## Example
4060

4161
For fully working examples, take a look at [`examples/`](https://github.com/transloadit/python-sdk/tree/HEAD/examples).

docs/source/index.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ Usage
6666
# or
6767
print(assembly_response.data['assembly_id'])
6868
69+
Async usage
70+
-----------
71+
72+
.. code:: python
73+
74+
from transloadit.async_client import AsyncTransloadit
75+
76+
async with AsyncTransloadit('TRANSLOADIT_KEY', 'TRANSLOADIT_SECRET') as tl:
77+
response = await tl.get_assembly(assembly_id='abc')
78+
print(response.data['ok'])
79+
80+
assembly = tl.new_assembly()
81+
assembly.add_step('resize', '/image/resize', {'width': 70, 'height': 70})
82+
with open('PATH/TO/FILE.jpg', 'rb') as upload:
83+
assembly.add_file(upload)
84+
response = await assembly.create(wait=True, resumable=False)
85+
86+
If you do not use ``async with``, call ``await tl.aclose()`` when you are done with the session.
87+
6988
Example
7089
-------
7190

docs/source/transloadit.rst

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,38 @@ transloadit.request module
4949
:undoc-members:
5050
:show-inheritance:
5151

52+
transloadit.async_client module
53+
-------------------------------
54+
55+
.. automodule:: transloadit.async_client
56+
:members:
57+
:undoc-members:
58+
:show-inheritance:
59+
60+
transloadit.async_assembly module
61+
----------------------------------
62+
63+
.. automodule:: transloadit.async_assembly
64+
:members:
65+
:undoc-members:
66+
:show-inheritance:
67+
68+
transloadit.async_template module
69+
----------------------------------
70+
71+
.. automodule:: transloadit.async_template
72+
:members:
73+
:undoc-members:
74+
:show-inheritance:
75+
76+
transloadit.async_request module
77+
--------------------------------
78+
79+
.. automodule:: transloadit.async_request
80+
:members:
81+
:undoc-members:
82+
:show-inheritance:
83+
5284
transloadit.response module
5385
---------------------------
5486

@@ -57,4 +89,3 @@ transloadit.response module
5789
:undoc-members:
5890
:show-inheritance:
5991

60-

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ classifiers = [
2525
"Topic :: Multimedia :: Sound/Audio :: Conversion",
2626
]
2727
dependencies = [
28+
"aiohttp>=3.13.5,<4",
2829
"requests>=2.33,<3",
2930
"tuspy>=1.0.0,<2.0.0",
3031
"urllib3>=2.7,<3",

0 commit comments

Comments
 (0)