kevin1024 / vcrpy

Automatically mock your HTTP interactions to simplify and speed up testing
MIT License
2.72k stars 388 forks source link

VCR.py causes infinite loop when used with requests.response.iter_content #636

Open prescod opened 2 years ago

prescod commented 2 years ago

This code prints ("A") but never gets to ("B")

import requests
import vcr

def download_file(uri):
    resp = requests.get(uri, stream=True)
    resp.raise_for_status()
    for chunk in resp.iter_content(chunk_size=None):
        print("READ", chunk[0:10])

download_file("https://www.example.com")
print("A")
with vcr.use_cassette("/tmp/cassette.yaml"):
    download_file("https://www.example.com")
print("B")