B V S S B X D I
B V S S B X D I
RRailway
Created by B V S S B X D I on 7/25/2023 in #✋|help
Python Flask app file upload memory leak
Yes that's exactly what happens
18 replies
RRailway
Created by B V S S B X D I on 7/25/2023 in #✋|help
Python Flask app file upload memory leak
Probably not because the python version is specified in the Ubuntu image in my dockerfile
18 replies
RRailway
Created by B V S S B X D I on 7/25/2023 in #✋|help
Python Flask app file upload memory leak
I solved the issue by using a different hosting provider...
18 replies
RRailway
Created by B V S S B X D I on 7/25/2023 in #✋|help
Python Flask app file upload memory leak
What kind of proof would be sufficient
18 replies
RRailway
Created by B V S S B X D I on 7/25/2023 in #✋|help
Python Flask app file upload memory leak
Hi Brody, thanks for the quick response, however, I still think it is a problem with Railway. The same code doesn't cause the memory leak described above on fly.io, render.com, local docker container, local machine, etc. the code is simply getting the file from a post request and saving it to the disk, something like
@cdn.route('/upload', methods=['GET', 'POST'])
def upload_file():
if file := request.files.get('file'):
...
file.save(full_path)
@cdn.route('/upload', methods=['GET', 'POST'])
def upload_file():
if file := request.files.get('file'):
...
file.save(full_path)
notes on the .save() method:
Save the file to a destination path or file object. If the destination is a file object you have to close it yourself after the call. The buffer size is the number of bytes held in memory during the copy process. It defaults to 16KB.
Using with open() to write the file using a chunked stream also causes the memory leak. Basically anytime I write a file to the disk it causes the memory leak.
18 replies