Optimized iterator exhaustion using collections.deque().
This commit is contained in:
parent
a8e2a9bac6
commit
5013d38380
|
@ -7,6 +7,7 @@ file upload handlers for processing.
|
||||||
import base64
|
import base64
|
||||||
import binascii
|
import binascii
|
||||||
import cgi
|
import cgi
|
||||||
|
import collections
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -565,9 +566,7 @@ def exhaust(stream_or_iterable):
|
||||||
iterator = iter(stream_or_iterable)
|
iterator = iter(stream_or_iterable)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
iterator = ChunkIter(stream_or_iterable, 16384)
|
iterator = ChunkIter(stream_or_iterable, 16384)
|
||||||
|
collections.deque(iterator, maxlen=0) # consume iterator quickly.
|
||||||
for __ in iterator:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def parse_boundary_stream(stream, max_header_size):
|
def parse_boundary_stream(stream, max_header_size):
|
||||||
|
|
Loading…
Reference in New Issue