Skip to content

Commit

Permalink
Return S3 reader wrapped by BufferedReader
Browse files Browse the repository at this point in the history
  • Loading branch information
belltailjp committed Dec 26, 2021
1 parent 69f87d8 commit d5f1f6c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pfio/v2/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from .fs import FS, FileStat


DEFAULT_BUFFER_SIZE = 32 * 1024 * 1024


def _normalize_key(key: str) -> str:
key = os.path.normpath(key)
if key.startswith("/"):
Expand Down Expand Up @@ -367,9 +370,7 @@ def open(self, path, mode='r', **kwargs):
if 'r' in mode:
obj = _ObjectReader(self.client, self.bucket, path, mode, kwargs)
if 'b' in mode:
# TODO: BufferedIOBase requires readinto() implemeted
# obj = io.BufferedReader(obj)
pass
obj = io.BufferedReader(obj, buffer_size=DEFAULT_BUFFER_SIZE)
else:
obj = io.TextIOWrapper(obj)

Expand Down

0 comments on commit d5f1f6c

Please sign in to comment.