Skip to content

Commit 94fcab5

Browse files
committed
Document bytes stream timeout
1 parent 444a87c commit 94fcab5

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

docs/api/get.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
::: obstore.get_ranges_async
99
::: obstore.GetOptions
1010
::: obstore.GetResult
11-
::: obstore.Buffer
11+
::: obstore.BytesStream
12+
::: obstore.Bytes
1213
::: obstore.OffsetRange
1314
::: obstore.SuffixRange

obstore/python/obstore/_buffer.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if sys.version_info >= (3, 12):
55
else:
66
from typing_extensions import Buffer as _Buffer
77

8-
class Buffer(_Buffer):
8+
class Bytes(_Buffer):
99
"""
1010
A buffer implementing the Python buffer protocol, allowing zero-copy access to the
1111
underlying memory provided by Rust.
@@ -15,4 +15,5 @@ class Buffer(_Buffer):
1515

1616
def to_bytes(self) -> bytes:
1717
"""Copy this buffer into a Python `bytes` object."""
18+
def __repr__(self) -> str: ...
1819
def __len__(self) -> int: ...

obstore/python/obstore/_get.pyi

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from datetime import datetime
22
from typing import List, Sequence, Tuple, TypedDict
33

44
from ._attributes import Attributes
5-
from ._buffer import Buffer
5+
from ._buffer import Bytes
66
from ._list import ObjectMeta
77
from .store import ObjectStore
88

@@ -199,7 +199,30 @@ class GetResult:
199199
"""
200200

201201
class BytesStream:
202-
"""An async stream of bytes."""
202+
"""An async stream of bytes.
203+
204+
!!! note "Request timeouts"
205+
The underlying stream needs to stay alive until the last chunk is polled. If the
206+
file is large, it may exceed the default timeout of 30 seconds. In this case,
207+
you may see an error like:
208+
209+
```
210+
GenericError: Generic {
211+
store: "HTTP",
212+
source: reqwest::Error {
213+
kind: Decode,
214+
source: reqwest::Error {
215+
kind: Body,
216+
source: TimedOut,
217+
},
218+
},
219+
}
220+
```
221+
222+
To fix this, set the `timeout` parameter in the `client_options` passed to the
223+
initial `get` or `get_async` call. See
224+
[ClientConfigKey][obstore.store.ClientConfigKey].
225+
"""
203226

204227
def __aiter__(self) -> BytesStream:
205228
"""Return `Self` as an async iterator."""
@@ -235,7 +258,7 @@ async def get_async(
235258
Refer to the documentation for [get][obstore.get].
236259
"""
237260

238-
def get_range(store: ObjectStore, path: str, start: int, end: int) -> Buffer:
261+
def get_range(store: ObjectStore, path: str, start: int, end: int) -> Bytes:
239262
"""
240263
Return the bytes that are stored at the specified location in the given byte range.
241264
@@ -251,21 +274,19 @@ def get_range(store: ObjectStore, path: str, start: int, end: int) -> Buffer:
251274
end: The end of the byte range (exclusive).
252275
253276
Returns:
254-
A `Buffer` object implementing the Python buffer protocol, allowing
277+
A `Bytes` object implementing the Python buffer protocol, allowing
255278
zero-copy access to the underlying memory provided by Rust.
256279
"""
257280

258-
async def get_range_async(
259-
store: ObjectStore, path: str, start: int, end: int
260-
) -> Buffer:
281+
async def get_range_async(store: ObjectStore, path: str, start: int, end: int) -> Bytes:
261282
"""Call `get_range` asynchronously.
262283
263284
Refer to the documentation for [get_range][obstore.get_range].
264285
"""
265286

266287
def get_ranges(
267288
store: ObjectStore, path: str, starts: Sequence[int], ends: Sequence[int]
268-
) -> List[Buffer]:
289+
) -> List[Bytes]:
269290
"""
270291
Return the bytes that are stored at the specified location in the given byte ranges
271292
@@ -281,14 +302,14 @@ def get_ranges(
281302
ends: A sequence of `int` where each offset ends (exclusive).
282303
283304
Returns:
284-
A sequence of `Buffer`, one for each range. This `Buffer` object implements the
305+
A sequence of `Bytes`, one for each range. This `Bytes` object implements the
285306
Python buffer protocol, allowing zero-copy access to the underlying memory
286307
provided by Rust.
287308
"""
288309

289310
async def get_ranges_async(
290311
store: ObjectStore, path: str, starts: Sequence[int], ends: Sequence[int]
291-
) -> List[Buffer]:
312+
) -> List[Bytes]:
292313
"""Call `get_ranges` asynchronously.
293314
294315
Refer to the documentation for [get_ranges][obstore.get_ranges].

obstore/python/obstore/_obstore.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ from ._copy import copy as copy
88
from ._copy import copy_async as copy_async
99
from ._delete import delete as delete
1010
from ._delete import delete_async as delete_async
11-
from ._get import Buffer as Buffer
11+
from ._get import Bytes as Bytes
12+
from ._get import BytesStream as BytesStream
1213
from ._get import GetOptions as GetOptions
1314
from ._get import GetResult as GetResult
1415
from ._get import OffsetRange as OffsetRange

0 commit comments

Comments
 (0)