You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm downloading files with async and streaming. It randomly fails, often when repeating. It could be related to #302 . I mostly get error 18, sometimes 55.
curl_cffi.requests.errors.RequestsError: Failed to perform, curl: (18) . See https://curl.se/libcurl/c/libcurl-errors.html first
or
for more details.
Traceback (most recent call last):
File "./loaders.py", line 225, in load
async for chunk in response.aiter_content():
File "./venv/lib/python3.11/site-packages/curl_cffi/requests/models.py", line 246, in aiter_content
raise chunk
curl_cffi.requests.errors.RequestsError: Failed to perform, curl: (55) Recv failure: Connection reset by peer. See https://curl.se/libcurl/c/libcurl-errors.html first for more details.
To Reproduce
asyncdeftest_curl_cffi_error():
fromcurl_cffi.requestsimportAsyncSessionhttp=AsyncSession()
# If using HTTP 1.1. it works# http = AsyncSession(http_version=CurlHttpVersion.V1_1)# Also tested beta# Note that some other URLs seems to work uri="https://kunskapsstyrningvard.se/download/18.888036617b192361ee22c6a/1628608381981/Vardforlopp-hjartsvikt-nydebuterad.pptx"# Brokenuri="https://firebasestorage.googleapis.com/v0/b/fictive-dev.appspot.com/o/videos%2Fdemo_e718ef.docx?alt=media&token=3ad7735f-212d-4372-b5b9-d5171a63d3c6"response=awaithttp.get(
uri,
default_headers=True,
stream=True,
impersonate="chrome",
)
length=0withtempfile.NamedTemporaryFile(delete=True) astemp:
asyncwithaiofiles.open(temp.name, "wb") asf:
asyncforchunkinresponse.aiter_content():
awaitf.write(chunk)
length+=len(chunk)
assertlength>0response.close()
awaitasyncio.sleep(1)
# if I reset the session between, it works# http = AsyncSession()# If I comment this out, it worksresponse=awaithttp.get(
uri,
default_headers=True,
stream=True,
impersonate="chrome",
)
length=0withtempfile.NamedTemporaryFile(delete=True) astemp:
asyncwithaiofiles.open(temp.name, "wb") asf:
asyncforchunkinresponse.aiter_content():
awaitf.write(chunk)
length+=len(chunk)
assertlength>0response.close()
Expected behavior
I expect that I can reuse a session and download files both in parallell and sequentially. Of course, I could reset the session every time as workaround but that could have other implications. Or is there a better way to stream files than aiofiles?
Versions
OS: MacOS
curl_cffi version 0.6.4 (also on 0.7.0b4)
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm downloading files with async and streaming. It randomly fails, often when repeating. It could be related to #302 . I mostly get error 18, sometimes 55.
or
To Reproduce
Expected behavior
I expect that I can reuse a session and download files both in parallell and sequentially. Of course, I could reset the session every time as workaround but that could have other implications. Or is there a better way to stream files than aiofiles?
Versions
The text was updated successfully, but these errors were encountered: