This is an automated email from the ASF dual-hosted git repository.
Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new edb97bd98e fix(bindings/python): coalesce AsyncFile writes with chunk
zero (#8647)
edb97bd98e is described below
commit edb97bd98e1d281f290343293ceaf40f394f9e63
Author: Xuanwo <[email protected]>
AuthorDate: Sun Nov 22 15:10:15 2026 +0800
fix(bindings/python): coalesce AsyncFile writes with chunk zero (#8647)
---
bindings/python/src/operator.rs | 4 ++--
bindings/python/tests/test_file_http_requests.py | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/bindings/python/src/operator.rs b/bindings/python/src/operator.rs
index d22800627b..68f180352f 100644
--- a/bindings/python/src/operator.rs
+++ b/bindings/python/src/operator.rs
@@ -1271,8 +1271,8 @@ impl AsyncOperator {
} else if mode == "wb" {
let mut writer_opts = writer_opts;
// Keep small writes coalesced when neither the caller nor the
- // service supplies a chunk size, as the AsyncWrite adapter
did.
- if writer_opts.chunk.is_none()
+ // service supplies a chunk size. The core treats zero as
unset.
+ if matches!(writer_opts.chunk, None | Some(0))
&& this.info().capability().write_multi_min_size.is_none()
{
writer_opts.chunk = Some(256 * 1024);
diff --git a/bindings/python/tests/test_file_http_requests.py
b/bindings/python/tests/test_file_http_requests.py
index 3000264b94..25ce472616 100644
--- a/bindings/python/tests/test_file_http_requests.py
+++ b/bindings/python/tests/test_file_http_requests.py
@@ -620,13 +620,14 @@ async def
test_async_file_cancelled_read_can_close(request_server):
@pytest.mark.asyncio
-async def test_async_file_coalesces_small_writes(request_server):
[email protected]("options", [{}, {"chunk": 0}], ids=["default",
"zero-chunk"])
+async def test_async_file_coalesces_small_writes(request_server, options):
endpoint, state = request_server
state._reset()
op = opendal.AsyncOperator(
"webdav", endpoint=endpoint, root="/", disable_create_dir="true"
)
- async with await op.open("file", "wb") as file:
+ async with await op.open("file", "wb", **options) as file:
for _ in range(1000):
assert await file.write(b"small") == 5
assert state._methods() == []