-
Notifications
You must be signed in to change notification settings - Fork 206
Add asyncio support #359
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
base: master
Are you sure you want to change the base?
Add asyncio support #359
Conversation
fix typo
Handle timeout in aread_response
Merge from upstream
* Comment annotation fixups * Added SdoServer aupload and adownload * Fix missing Network.is_async() uses * Fix workaround in pdo.map.save/asave
What is the best way to deal with var = param.data # Non-async use
var = await param.aget_data() # Async use My goal has been to keep the async and non-async uses of canopen as equal as possible, but this is an area where users will see a difference. |
There is an implementation for |
@acolomb I'm not precisely sure what you mean, so let me guess: You need separate |
Sorry, I was trying to answer your question in the previous comment about synchronous getters / setters used in the properties. What I meant was that instead we already do have methods to access a variable remotely. Those might be a better fit to mirror to the async world: value = sdo_var.raw # This is the usual, terse style recommended in the docs
value = sdo_var.read(fmt='raw') # This also works already
value = await sdo_var.aread(fmt='raw') # Feels like a natural enhancement for async Note that the |
* Move loop init to the Network * Remove unused callbacks in LocalNode
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #359 +/- ##
==========================================
- Coverage 71.36% 69.03% -2.34%
==========================================
Files 26 27 +1
Lines 3129 3397 +268
Branches 480 523 +43
==========================================
+ Hits 2233 2345 +112
- Misses 765 906 +141
- Partials 131 146 +15
|
* Thread dependent sentinel guard
* All callbacks are synchronous and same in both sync and async mode * Sync waiting is done with `asyncio.to_thread()` from async
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
* Make code more similar the upstream code * Implement missing async functions * Update README.rst and example * Revert test cases to be diffable with upstream * Ensure all skipTest() have useful messages * Wash FIXMEs and NOTEs
* Adding `AllowBlocking` for temporary pausing the async guard * skipTest() cleanup * Increase test coverage
* OD object lookup issue * SDO testing warning issue
* Fixed uncovered bugs * Bumped minimum py version to 3.9 (due to asyncio compatibility) * Added tests for PDO to increase coverage
This branch is ready for review and integration into the project. Its not fully complete (I suppose it never will). The biggest lack is that there is no documentation for async. The branch's README (https://github.com/sveinse/canopen-asyncio?tab=readme-ov-file#difference-between-async-and-non-async-version) contains an overview over the current differences between this branch and the main project. The port is quite "naive" async-wise as it relies on |
This PR adds support of asyncio to canopen. The overall goals is to make canopen able to be used in either with asyncio or regular synchronous mode (but not at the same time) from the same code base.
Note that this work is still work in progress. This PR was created to discuss the specific solutions for async and non-async as mentioned in #272. This PR closes #272.
Current status until feature complete:
ImplementNot neededABlockUploadStream
,ABlockDownloadStream
andATextIOWrapper
for async inSdoClient
.EcmyConsumer.wait()
for asyncAsync implementation ofOnlyLssMaster
fast_scan
BaseNode402
~Omitted for nowNetwork.add_node()