Python: requests.get ignores the last record
<p>This is my code:</p>

<pre><code>response = requests.get(apiurl+'api/v1/watch/services',
                         auth=(apiuser,apipass), verify=False, stream=True)
for line in response.iter_lines():
    try:
        data = json.loads(line.decode('utf-8'))
        pprint.pprint(data)
    except Exception as e:
        pprint.pprint(e)
        pass
</code></pre>

<p>Please note the <code>stream=True</code>.</p>

<p>The problem is, when I have <code>a</code> <code>b</code> <code>c</code> <code>d</code> on the input, the script just outputs <code>a</code> <code>b</code> and <code>c</code>. Then, when <code>e</code> comes on input, the script outputs <code>d</code>.</p>

<p>What am I doing wrong?</p>

<p>OK so the answer is a bit unexpected for me.</p>

<p>Updating python from 3.4 to 3.5 helped, nothing else changed.</p>

<p>Hope this answer helps someone else fighting this problem.</p>

python python-requests