Caput with callback#98
Merged
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #98 +/- ##
==========================================
+ Coverage 87.63% 87.72% +0.08%
==========================================
Files 13 14 +1
Lines 930 961 +31
==========================================
+ Hits 815 843 +28
- Misses 115 118 +3
Continue to review full report at Codecov.
|
Includes a "blocking" flag on record creation. This change allows you to use caput in asynchronous mode, where it will wait for record processing to complete.
This implementation still leaks abstractions - the device now needs to know about the difference between cothread and async calls. Perhaps another round of refactoring is required...
Also add single and multi threaded tests for blocking records.
Renamed the function to conform to naming convention. Added CHANGELOG entry.
7fa6838 to
0591f51
Compare
This leaks even more async code into the device, but I can't see a way around it without having to require the dispatcher be provided before creating records...
By creating/modifying the dispatchers we can easily handle the __completion being called after the __on_update. Without doing this there seem to be unavoidable implementation leaks, where the device.py file would have to care about the difference between cothread and asyncio.
Araneidae
approved these changes
Jul 29, 2022
Araneidae
left a comment
Collaborator
There was a problem hiding this comment.
Looks pretty good. Have a couple of coding changes to suggest, particularly the asyncio dispatcher, but I think this is a huge success.
After all the pain this has come out a lot more cleanly than I was expecting!
a0bce0c to
3f12ef8
Compare
- SetBlocking returns the old blocking state value. Added test. - Fix some style issues - Make completion function on the dispatcher optional, to maintain some compatibility with the previous API
3f12ef8 to
877a89c
Compare
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.
Add blocking to the processing of
on_update/on_update_namecallbacks, to allowcaputto correctly wait for processing to complete before returning.Documented the new
blockingflag on OUT record creation, and theSetBlockingfunction. I didn't document the CothreadDispatcher, as there's no reason for any users to explicitly create it themselves. Let me know if I should document it, or perhaps change its name to indicate its internal-only.Tests written:
ProcessDeviceSupportOutclasscaputrequests from both a single thread multiple times and from multiple threads simultaneously.