-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
read_chunk wait forever when client aborts file uploading #4747
Comments
Has this been fixed? |
you can see where it throws from the log below
BTW, do you have any plan for the new version? |
Have you tried version 4.0.1a? |
@WisdomPill No. Pip will install 3.6.2 by default and it's problematic. The master branch is 4.0.0a and it works. |
you can install it using pip like the following regarding the new release follow here https://aio-libs.discourse.group/t/aiohttp-new-release/49 as suggested in #4516 |
Finnally I figured it out. here is a simple demo handler async def store_mp3_handler(request):
reader = await request.multipart()
# /!\ Don't forget to validate your inputs /!\
# reader.next() will `yield` the fields of your form
field = await reader.next()
assert field.name == 'mp3_2'
filename = field.filename
# You cannot rely on Content-Length if transfer is chunked.
size = 0
try:
with open(filename, 'wb') as f:
print('begin')
while True:
# pdb.set_trace()
chunk = await field.read_chunk(1024*1024) # 8192 bytes by default.
if not chunk:
break
print(len(chunk))
size += len(chunk)
f.write(chunk)
sleep(1)
print('end')
except:
logging.exception('oops')
return web.Response(text='{} sized of {} successfully stored'
''.format(filename, size)) In order to simulate abort uploading, just close the browser while uploading is still in progress |
logging.exception('oops') output
|
🐞 Describe the bug
When I am uploading files to the server using ajax,the server's
read_chunk
does not raise any exception when client ajax aborts. That is, the server's handler will wait foreever.💡 To Reproduce
Quickstart -> File Uploads
https://docs.aiohttp.org/en/stable/web_quickstart.html#file-uploads
💡 Expected behavior
An exception should be raised
📋 Logs/tracebacks
📋 Your version of the Python
📋 Your version of the aiohttp/yarl/multidict distributions
📋 Additional context
server
The text was updated successfully, but these errors were encountered: