summaryrefslogtreecommitdiff
path: root/django/http/multipartparser.py
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2019-01-15 13:11:02 +0000
committerTim Graham <timograham@gmail.com>2019-02-14 18:21:57 -0500
commit5013d38380f19cdbc651ec2978b9b77955fddae5 (patch)
tree07bda57c304e3bb0f1b0a9ff3b06413d35fb4fd0 /django/http/multipartparser.py
parenta8e2a9bac6e548d6ab2e13af6171d2fdd3b8055b (diff)
Optimized iterator exhaustion using collections.deque().
Diffstat (limited to 'django/http/multipartparser.py')
-rw-r--r--django/http/multipartparser.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index e235024d0e..958b519dc3 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -7,6 +7,7 @@ file upload handlers for processing.
import base64
import binascii
import cgi
+import collections
from urllib.parse import unquote
from django.conf import settings
@@ -565,9 +566,7 @@ def exhaust(stream_or_iterable):
iterator = iter(stream_or_iterable)
except TypeError:
iterator = ChunkIter(stream_or_iterable, 16384)
-
- for __ in iterator:
- pass
+ collections.deque(iterator, maxlen=0) # consume iterator quickly.
def parse_boundary_stream(stream, max_header_size):