-
Notifications
You must be signed in to change notification settings - Fork 9
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
Caput with callback #98
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.
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.
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
Add blocking to the processing of
on_update
/on_update_name
callbacks, to allowcaput
to correctly wait for processing to complete before returning.Documented the new
blocking
flag on OUT record creation, and theSetBlocking
function. 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:
ProcessDeviceSupportOut
classcaput
requests from both a single thread multiple times and from multiple threads simultaneously.