Skip to content

Instantly share code, notes, and snippets.

@squiddy
Created December 13, 2013 11:38
Show Gist options
  • Save squiddy/7943093 to your computer and use it in GitHub Desktop.
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
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