Skip to content
Myr

Document Response.iter_lines() reentrancy issues

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Priit Laes · committed by Priit Laes · parent 62200cb · Browse files · 2 files+15 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+15 added−0 removed

  • other:+15 added−0 removed

2 files+15 added−0 removed

modified:docs/user/advanced.rst+13 added
397 unmodified lines
398 # filter out keep-alive new lines399 if line:400 print(json.loads(line))401402.. warning::403404 :class:`~requests.Response.iter_lines()` is not reentrant safe.405 Calling this method multiple times causes some of the received data406 being lost. In case you need to call it from multiple places, use407 the resulting iterator object instead::408409 lines = r.iter_lines()410 # Save the first line for later or just skip it411 first_line = next(lines)412 for line in lines:413 print(line)414415.. _proxies:416417Proxies418-------
393 unmodified lines
modified:requests/models.py+2 added
686 unmodified lines
687 def iter_lines(self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=None, delimiter=None):688 """Iterates over the response data, one line at a time. When689 stream=True is set on the request, this avoids reading the690 content at once into memory for large responses.691692 .. note:: This method is not reentrant safe.693 """694695 pending = None696
145 unmodified lines