Skip to content

Commit 75a6f4e

Browse files
author
Thomas Gilgenast
committed
delegate HTTPFile creation to HTTPFileSystem.open()
1 parent 7d88086 commit 75a6f4e

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

fsspec/implementations/github.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import requests
44

5-
from ..asyn import get_loop, sync
65
from ..spec import AbstractFileSystem
76
from ..utils import infer_storage_options
8-
from .http import HTTPFile, HTTPFileSystem
7+
from .http import HTTPFileSystem
98
from .memory import MemoryFile
109

1110
# TODO: add GIST backend, would be very similar
@@ -65,11 +64,7 @@ def __init__(
6564

6665
self.root = sha
6766
self.ls("")
68-
69-
# prepare elements needed to return HTTPFile
7067
self.http_fs = HTTPFileSystem(**kwargs)
71-
self.loop = get_loop()
72-
self.session = sync(self.loop, self.http_fs.set_session)
7368

7469
@property
7570
def kw(self):
@@ -219,7 +214,6 @@ def _open(
219214
path,
220215
mode="rb",
221216
block_size=None,
222-
autocommit=True,
223217
cache_options=None,
224218
sha=None,
225219
**kwargs,
@@ -252,16 +246,11 @@ def _open(
252246

253247
# we land here if the content was not present in the first response
254248
# (regular file over 1MB or git-lfs tracked file)
255-
# in this case, we get return an HTTPFile object wrapping the
256-
# download_url
257-
return HTTPFile(
258-
self.http_fs,
249+
# in this case, we get let the HTTPFileSystem handle the download
250+
return self.http_fs.open(
259251
content_json["download_url"],
260-
session=self.session,
252+
mode=mode,
261253
block_size=block_size,
262-
autocommit=autocommit,
263254
cache_options=cache_options,
264-
size=content_json["size"],
265-
loop=self.loop,
266255
**kwargs,
267256
)

0 commit comments

Comments
 (0)