Repository navigation
Conversation
I've added "stream" as a message type, and provided "next message" and "close streams by affordance" methods. This should prepare the way for using MessageBroker for MJPEG streams.
The thing server interface now exposes the message broker.
This strips out the pub/sub logic from MJPEGStream in favour of using MessageBroker, as is already done for property notifications. The resulting class should be much simpler. I've also inherited from BaseDescriptor to save duplication in MJPEGStreamDescriptor.
Barecheck - Code coverage reportTotal: 97.77%Your code coverage diff: 0.34% ▴ Uncovered files and lines
|
This uses an event to speed up tests by eliminating `time.sleep` and adds some more checks on the data received.
The stream no longer has the notion of being "active" so we can't check for errors there. This might be a feature we want to revive - I'm not totally sure.
This is tested by a better-isolated test that mocks the server and uses a real MessageBroker.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR strips out the custom pub/sub logic from
MJPEGStreamand replaces it with a couple of calls toMessageBroker. It goes further than #372 by actually using theMessageBrokerobject rather than just pinching a function from it. I think this results in a bigger improvement, from a smaller code change.I hope this makes the code much more readable and much more testable.
The diff has more additions than deletions - but the deletions are (complicated) code while the additions are docstrings, comments, tests, and calls to much clearer code.
The pub/sub logic in MessageBroker is tested much more carefully than the old logic was, even though it was technically covered before.
I think I now understand how to write some better async tests for MJPEGStream, but I'll leave that for a future PR. This PR passes both the old tests, and the relevant bits of the improved tests in #372, which are included in this PR.
OFM-Feature-Branch: v3-mjpeg-stream-refactor
This MR contains the following
Before merge:
Merge checklist:
docs/src/public_api.rst.New or changed features have been added to (or updated in) the conceptual documentation.Any new or updated dependencies have been added to the project configuration (e.g.,pyproject.toml).Any decrease in test coverage has been justified.test-against-ofm-v3job passes, ortest-against-ofm-feature-branchpasses.New features have been used in a branch of the OpenFlexure Microscope, which is tested intest-against-ofm-feature-branch.