-
Notifications
You must be signed in to change notification settings - Fork 4
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 the issue of api.get_zone_status_stream not return after timeout #25
base: master
Are you sure you want to change the base?
Conversation
… the long connection alive when there is no analyzing results
int(s_id): {key: bf_codecs.ZoneStatus.from_dict(val) | ||
for key, val in statuses.items()} | ||
for s_id, statuses in zone_statuses_dict.items()} | ||
processed={} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processed={} | |
processed = {} |
int(s_id): {key: bf_codecs.ZoneStatus.from_dict(val) | ||
for key, val in statuses.items()} | ||
for s_id, statuses in zone_statuses_dict.items()} | ||
processed={} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the point in yielding an empty byte. Please return the to the previous implementation (using continue
), unless there was a specific reason to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes the issue where the client is stuck there and never returns if a stream is gone before the client exits, the request will timeout, but API never returns. @leefrank9527
There are three commits to this change. The real change is only the two lines:
|
int(s_id): {key: bf_codecs.ZoneStatus.from_dict(val) | ||
for key, val in statuses.items()} | ||
for s_id, statuses in zone_statuses_dict.items()} | ||
processed={} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change will cause downstream problems. Returning {}
has semantic meaning: It means there are 0 streams.
Feel free to merge it, but consider instead raising an exception, or returning a sentinal value such as None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apockill In some scenarios the streams will stop and be removed after running a while, so the {} is expected for these scenarios. Maybe when there are streams running, an empty string or {} will return occasionally. If so an incompatible problem may happen. Anyway, with this mechanism, the API can tell the application what happened and the application can make a decision according to the return values.
Currently, get_zone_status_stream will freeze when a video stream stops; timeout will not work. This can be reproduced if we host a stream using ffmeg/ffserver, use it as ip camera input of brainframe, and wait till the end of video file playback.
The solution implemented here is to return an empty json once we reach timeout.