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 b788d4f731 fix(bindings/python): coalesce synchronous File writes with
chunk zero (#8648)
b788d4f731 is described below
commit b788d4f73139ba8d07d7a58abed1b759b01960ac
Author: Xuanwo <[email protected]>
AuthorDate: Sun Nov 22 16:23:19 2026 +0800
fix(bindings/python): coalesce synchronous File writes with chunk zero
(#8648)
---
bindings/python/src/operator.rs | 4 ++--
bindings/python/tests/test_file_http_requests.py | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/bindings/python/src/operator.rs b/bindings/python/src/operator.rs
index 68f180352f..ad7ab0214b 100644
--- a/bindings/python/src/operator.rs
+++ b/bindings/python/src/operator.rs
@@ -424,8 +424,8 @@ impl Operator {
} else if mode == "wb" {
let mut writer_opts = writer_opts;
// Keep small writes coalesced without the std::io adapter when
- // neither the caller nor the service supplies a chunk size.
- if writer_opts.chunk.is_none()
+ // neither the caller nor the service supplies a nonzero chunk
size.
+ 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 25ce472616..888019d14e 100644
--- a/bindings/python/tests/test_file_http_requests.py
+++ b/bindings/python/tests/test_file_http_requests.py
@@ -265,11 +265,13 @@ def
test_sync_file_sequential_read_uses_one_request(request_server):
file.read(1)
-def test_sync_file_flush_keeps_small_writes_coalesced(request_server):
[email protected]("chunk", [None, 0], ids=["default", "zero"])
+def test_sync_file_flush_keeps_small_writes_coalesced(request_server, chunk):
endpoint, state = request_server
state._reset()
op = opendal.Operator("webdav", endpoint=endpoint,
disable_create_dir="true")
- with op.open("file", "wb") as file:
+ options = {} if chunk is None else {"chunk": chunk}
+ with op.open("file", "wb", **options) as file:
for _ in range(1000):
assert file.write(b"small") == 5
file.flush()