quart icon indicating copy to clipboard operation
quart copied to clipboard

Quart handling requests "simultaneously"

Open GoedendagMC opened this issue 2 years ago • 1 comments

I have a file upload handler, structured as follows (simplified):

print('filename= ' + file.filename)
await aiofiles.os.mkdir(filefolder)
print("folder made")
await file.save(os.path.join("/filefolder", filename))
print("file saved")
return '',200

The folder path changes depending on a header sent in the request. Now, when I send several POST requests to upload, instead of handling each of them as would be normal, it groups all the filename prints, then all the foldermade prints, then all the filesaved prints. Is this normal behaviour?

It is problematic, because when multiple files are uploaded at once, it can take a very long time, as they are all run at the same time instead of one (or a few) after another.

Related question: say I hosted this upload handler 10 times, on 10 different URLs, would the performance be better? If so, is there no way to simulate this from just one file?

I use Hypercorn as ASGI, Nginx reverse proxy after that.

Thanks in advance!

GoedendagMC avatar May 18 '22 19:05 GoedendagMC

That's how async works ... The file saving is handled in parallel.

laggardkernel avatar Jul 07 '22 02:07 laggardkernel