Created
December 13, 2013 11:38
-
-
Save squiddy/7943093 to your computer and use it in GitHub Desktop.
Artificially slow down upload speed on flask apps to test file upload progress events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In werkzeug.formparser change MultiPartParser.parse_parts. Look for | |
elif ellt == _cont: | |
_write(ell) | |
# if we write into memory and there is a memory size limit we | |
# count the number of bytes in memory and raise an exception if | |
# there is too much data in memory. | |
if guard_memory: | |
in_memory += len(ell) | |
if in_memory > self.max_form_memory_size: | |
self.in_memory_threshold_reached(in_memory) | |
Add a sleep before/after the write. time.sleep(0.001) makes a 300MB file upload in about 5-10s. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment