Spaces:
Running
Running
jamelloverz-sketch commited on
Commit ·
d2badfd
1
Parent(s): 938468e
chunk size 1MB for 2-3x throughput improvement
Browse files
app.py
CHANGED
|
@@ -129,7 +129,7 @@ def stream_from_hf(dataset, file_path, wfile, range_start=0, range_end=None):
|
|
| 129 |
resp = urllib.request.urlopen(req, timeout=300)
|
| 130 |
total = int(resp.headers.get("Content-Length", 0))
|
| 131 |
while True:
|
| 132 |
-
chunk = resp.read(
|
| 133 |
if not chunk:
|
| 134 |
break
|
| 135 |
wfile.write(chunk)
|
|
@@ -299,7 +299,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
|
| 299 |
f.seek(start)
|
| 300 |
remaining = length
|
| 301 |
while remaining > 0:
|
| 302 |
-
chunk_size = min(
|
| 303 |
chunk = f.read(chunk_size)
|
| 304 |
if not chunk:
|
| 305 |
break
|
|
@@ -352,7 +352,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
|
| 352 |
try:
|
| 353 |
tmpf = open(temp, "wb") if temp else None
|
| 354 |
while True:
|
| 355 |
-
chunk = hf_resp.read(
|
| 356 |
if not chunk:
|
| 357 |
break
|
| 358 |
if tmpf:
|
|
|
|
| 129 |
resp = urllib.request.urlopen(req, timeout=300)
|
| 130 |
total = int(resp.headers.get("Content-Length", 0))
|
| 131 |
while True:
|
| 132 |
+
chunk = resp.read(1048576)
|
| 133 |
if not chunk:
|
| 134 |
break
|
| 135 |
wfile.write(chunk)
|
|
|
|
| 299 |
f.seek(start)
|
| 300 |
remaining = length
|
| 301 |
while remaining > 0:
|
| 302 |
+
chunk_size = min(1048576, remaining)
|
| 303 |
chunk = f.read(chunk_size)
|
| 304 |
if not chunk:
|
| 305 |
break
|
|
|
|
| 352 |
try:
|
| 353 |
tmpf = open(temp, "wb") if temp else None
|
| 354 |
while True:
|
| 355 |
+
chunk = hf_resp.read(1048576)
|
| 356 |
if not chunk:
|
| 357 |
break
|
| 358 |
if tmpf:
|