Closed chenming219 closed 2 years ago
You can use a with bottle.request.body:
block to prevent the resource warning and properly close the request body.
Automatically closing the body after each request would break backwards compatibility because it is currently allowed to move body processing to a separate thread or access the body after the request was already closed.
so,follow your suggestion, I suggest to edit the example code for File Uploads in https://bottlepy.org/docs/dev/tutorial.html, This sample code does not close the file handle properly
We have a fix now in master branch that avoids the ResourceWarning
. Still not perfect, but It'll do for now.
The example below, have a bug that cannot close body fd and also cannot close upload.file
suggest to change to the following code, or add self.body.close() in POST function and add self.file.close() in save function