Skip to content

Commit 676b7b6

Browse files
authored
Implement tell for async stream reader (#741)
1 parent 42c3e9c commit 676b7b6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

s3fs/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2295,13 +2295,16 @@ def __init__(self, fs, path, mode):
22952295
self.path = path
22962296
self.mode = mode
22972297
self.r = None
2298+
self.loc = 0
22982299

22992300
async def read(self, length=-1):
23002301
if self.r is None:
23012302
bucket, key, gen = self.fs.split_path(self.path)
23022303
r = await self.fs._call_s3("get_object", Bucket=bucket, Key=key)
23032304
self.r = r["Body"]
2304-
return await self.r.read(length)
2305+
out = await self.r.read(length)
2306+
self.loc += len(out)
2307+
return out
23052308

23062309

23072310
def _fetch_range(fs, bucket, key, version_id, start, end, req_kw=None):

s3fs/tests/test_s3fs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,7 @@ async def read_stream():
26142614
f = await fs.open_async(fn, mode="rb", block_seze=1000)
26152615
while True:
26162616
got = await f.read(1000)
2617+
assert f.tell()
26172618
if not got:
26182619
break
26192620
out.append(got)

0 commit comments

Comments
 (0)