Skip to content

Commit fc8438e

Browse files
authored
Expose buffer_size kwarg in open_reader (#3)
1 parent e3b20e1 commit fc8438e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/obspec_utils/file_handlers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
class ObstoreReader:
1515
_reader: ReadableFile
1616

17-
def __init__(self, store: ObjectStore, path: str) -> None:
17+
def __init__(
18+
self, store: ObjectStore, path: str, buffer_size: int = 1024 * 1024
19+
) -> None:
1820
"""
1921
Create an obstore file reader that implements the read, readall, seek, and tell methods, which
2022
can be used in libraries that expect file-like objects.
@@ -27,8 +29,10 @@ def __init__(self, store: ObjectStore, path: str) -> None:
2729
[ObjectStore][obstore.store.ObjectStore] for reading the file.
2830
path
2931
The path to the file within the store. This should not include the prefix.
32+
buffer_size
33+
The minimum number of bytes to read in a single request. Up to buffer_size bytes will be buffered in memory.
3034
"""
31-
self._reader = obs.open_reader(store, path)
35+
self._reader = obs.open_reader(store, path, buffer_size=buffer_size)
3236

3337
def read(self, size: int, /) -> bytes:
3438
return self._reader.read(size).to_bytes()

0 commit comments

Comments
 (0)