Skip to content

Commit 695f784

Browse files
jacalataclaude
andcommitted
fix: increase streaming chunk size for CSV and Excel view downloads
Raises iter_content chunk size from 1024 to 65536 bytes in _get_view_csv and _get_view_excel. The 1-KB default required ~200k iterations for a 200 MB download, causing apparent hangs when callers materialise the full stream with b''.join(view.csv). Closes #1374 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5379cc8 commit 695f784

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tableauserverclient/server/endpoint/views_endpoint.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import logging
22
from contextlib import closing
33

4+
from tableauserverclient.config import BYTES_PER_MB, config
5+
46
from tableauserverclient.models.permissions_item import PermissionsRule
57
from tableauserverclient.server.endpoint.endpoint import QuerysetEndpoint, api
68
from tableauserverclient.server.endpoint.exceptions import MissingRequiredFieldError, UnsupportedAttributeError
@@ -264,7 +266,7 @@ def _get_view_csv(self, view_item: ViewItem, req_options: "CSVRequestOptions | N
264266
url = f"{self.baseurl}/{view_item.id}/data"
265267

266268
with closing(self.get_request(url, request_object=req_options, parameters={"stream": True})) as server_response:
267-
yield from server_response.iter_content(1024)
269+
yield from server_response.iter_content(config.CHUNK_SIZE_MB * BYTES_PER_MB)
268270

269271
@api(version="3.8")
270272
def populate_excel(self, view_item: ViewItem, req_options: "ExcelRequestOptions | None" = None) -> None:
@@ -303,7 +305,7 @@ def _get_view_excel(self, view_item: ViewItem, req_options: "ExcelRequestOptions
303305
url = f"{self.baseurl}/{view_item.id}/crosstab/excel"
304306

305307
with closing(self.get_request(url, request_object=req_options, parameters={"stream": True})) as server_response:
306-
yield from server_response.iter_content(1024)
308+
yield from server_response.iter_content(config.CHUNK_SIZE_MB * BYTES_PER_MB)
307309

308310
@api(version="3.2")
309311
def populate_permissions(self, item: ViewItem) -> None:

0 commit comments

Comments
 (0)