Skip to content

Commit 6380e4b

Browse files
Expose max_total_rows via DqliteConnection; cap now configurable
Cycle 8 — DqliteProtocol.max_total_rows was added in cycle 1 but only as a protocol-layer knob with no way to override it from the public API. DqliteConnection now accepts max_total_rows=... and threads it through when constructing its protocol. Applications that legitimately need larger result sets can now raise or disable the cap without reaching into private internals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ab15a82 commit 6380e4b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/dqliteclient/connection.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,18 @@ def __init__(
7474
*,
7575
database: str = "default",
7676
timeout: float = 10.0,
77+
max_total_rows: int | None = 10_000_000,
7778
) -> None:
7879
"""Initialize connection (does not connect yet).
7980
8081
Args:
8182
address: Node address in "host:port" format
8283
database: Database name to open
8384
timeout: Connection timeout in seconds
85+
max_total_rows: Cumulative row cap across continuation
86+
frames for a single query. Prevents a slow-drip server
87+
from keeping the client alive indefinitely within the
88+
per-operation deadline. Set to ``None`` to disable.
8489
"""
8590
import math
8691

@@ -89,6 +94,7 @@ def __init__(
8994
self._address = address
9095
self._database = database
9196
self._timeout = timeout
97+
self._max_total_rows = max_total_rows
9298
self._protocol: DqliteProtocol | None = None
9399
self._db_id: int | None = None
94100
self._in_transaction = False
@@ -140,7 +146,12 @@ async def connect(self) -> None:
140146
except OSError as e:
141147
raise DqliteConnectionError(f"Failed to connect to {self._address}: {e}") from e
142148

143-
self._protocol = DqliteProtocol(reader, writer, timeout=self._timeout)
149+
self._protocol = DqliteProtocol(
150+
reader,
151+
writer,
152+
timeout=self._timeout,
153+
max_total_rows=self._max_total_rows,
154+
)
144155

145156
try:
146157
await self._protocol.handshake()

0 commit comments

Comments
 (0)