Skip to content

Add asyncio support #388

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

Merged
merged 13 commits into from
Sep 5, 2018

Conversation

christiansandberg
Copy link
Collaborator

Adds support for developing asyncio applications with python-can more easily. This can be useful when implementing protocols that handles simultaneous connections to many nodes since you can write synchronous looking code without handling multiple threads and locking mechanisms.

For information I started working a year ago or so on adding native asyncio support for each interface but abandoned it since not all API's support callbacks and the performance would probably be worse than using a thread for reading messages.

@felixdivo
Copy link
Collaborator

Uhh, looks really nice!

@codecov
Copy link

codecov bot commented Aug 11, 2018

Codecov Report

Merging #388 into develop will increase coverage by <.01%.
The diff coverage is 63.75%.

@@             Coverage Diff             @@
##           develop     #388      +/-   ##
===========================================
+ Coverage    59.25%   59.26%   +<.01%     
===========================================
  Files           55       55              
  Lines         4261     4328      +67     
===========================================
+ Hits          2525     2565      +40     
- Misses        1736     1763      +27

@felixdivo felixdivo requested a review from hardbyte August 15, 2018 14:25
@felixdivo
Copy link
Collaborator

Could you add a test for this on Python 3.4+? This could basically test the same behavior as the normal BufferedReader to cover both, right? Maybe in python-can/test/listener_test.py.

@christiansandberg
Copy link
Collaborator Author

The problem is that testing this will require statements that are not available in Python 2.7 so it won’t even be able to read the file. Not sure if that can be handled by pytest.

@felixdivo
Copy link
Collaborator

Hm, I see.

Copy link
Owner

@hardbyte hardbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

I tried it out on python 3.6 and saw messages on a vcan bus, and verified that the new test correctly gets skipped on python 2.7.

Thanks for your patience with this addition

@hardbyte hardbyte added this to the 2.3 Release milestone Aug 31, 2018
@christiansandberg christiansandberg merged commit c83ee71 into hardbyte:develop Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants