What's wrong with this Python streaming response?

What's wrong with this Python streaming response in an API. The Python code closes the database cursor before the generator is consumed, so the stream fails mid response. In Python services this causes partial downloads.

#whatswrongwiththispythoncode #pythonbug #pythonproductionbug #pythondebugging #pythonbackend #pythoncodereview #pythonmistake #pythonbestpractices #pythonreliability #pythonincid...

https://www.youtube.com/watch?v=MqjVyD53Uic

Whats wrong with this Python streaming response? #pythondataloss

YouTube