Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix last line of stream being stuck in buffer #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BlindChickens
Copy link

requests.Response.iter_lines has a known issue where it will not return a line if the bytes in that line is less than the minimum size and it's the last line.
psf/requests#3577

In my case it caused events to only be picked up when the next event came in from the DVR. So the motion event would only register when the next videoloss event came in or some other event.

Basically means the latest event is just never picked up. The second latest event according to the DVR will alway be the last one interpreted by the library.

In real life this caused my motion events to notify my home assistant with considerable lag. Up to 10 seconds.

@mezz64
Copy link
Owner

mezz64 commented Jul 9, 2022

Thanks for the PR! Change looks simple enough. I'll try to find some time this weekend to do some tests and if all is well I'll get it merged and do a version bump.

@mezz64
Copy link
Owner

mezz64 commented Sep 3, 2022

Sorry for the slow response on this. While this change functions fine, I'm not too keen on the performance impact. In my test cases it's 6-7x more resource intensive than the existing implementation. Have you tried doing bigger chunks, yet smaller than the iter_line default to see if we can fix the issue, yet not increase the resources so much?

I don't see this behavior on my cams (the videoloss events are frequent) so it's hard for me to know if a larger chunk will still fix your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants