Evaluate switching from txdbus to other Python DBus package
See original GitHub issueDescription
A problem with using txdbus as the solution to talk to the BlueZ DBus service is that it seems to leak file descriptors somewhere. Right now this is solved by having a store of twisted reactors in the __init__.py
of bleak.backends.bluez
.
This might be improved by using another package. Candidates to evaluate:
- DBussy: https://github.com/ldo/dbussy
- Jeepney: https://jeepney.readthedocs.io/en/latest/
Pros
- Both are pure python and would reduce the number of dependencies for bleak
- It might resolve the file descriptor problem
- An
asyncio
-only solution in Linux
Cons
- Twisted (which powers txdbus) is a very stable and efficient package. Replacing it with newer, less tested packages might lead to unexpected problems.
Issue Analytics
- State:
- Created 3 years ago
- Comments:34 (22 by maintainers)
Top Results From Across the Web
A brand new website interface for an even better experience!
Evaluate switching from txdbus to other Python DBus package.
Read more >dbus-python tutorial — dbus-python 1.3.2 documentation
D-Bus applications can export objects for other applications' use. To start working with an object in another application, you need to know:.
Read more >DbusExamples - Python Wiki
txdbus is a native Python implementation of the D-Bus protocol for the Twisted networking framework. dbus-next is a native Python library ...
Read more >txdbus - PyPI
A native Python implementation of the DBus protocol for Twisted applications.
Read more >pip failed to install dbus-python - Stack Overflow
First I looked up for package sudo apt-cache search dbus-1. Then I installed required packages with command: sudo apt install libdbus-1-3 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hbldh Thank you for the detailed response. Indeed, I agree that Bleak is the of the various attempts that I have worked with, hence my current involvement in this repository. Thank you for all of your work! 🙏
I did start down the gattlib as a Bleak backend path out of curiosity but have since pulled the plug. For interested parties, it does seem to be possible to make it play nicely with async, you can see my branches here: bleak and https://github.com/Allthenticate/gattlib/tree/development. It appears that D-Bus in general is the bottleneck and not the Python code in particular. I ran some tests in pure C vs. the Python version and did not see much difference, unfortunately. The library that I was comparing the speed against was bluepy. However, it appears that are circumventing D-Bus and doing some hacky stuff where they are wrapping a compiled binary with Python to get that speed gain.
The only way I’ve really found to get our CPU usage down is by adding scanning filters or, in our case, acting as a peripheral instead of a central. Thus, I plan to jump on board with bless and help push that forward.
I think I would be in favor of exploring one of the alternatives. I did some work last year to fix some bugs in txdbus. One bug (that fortunately doesn’t affect Bleak) I was not able to fix because it would require changing twisted, but I found it to just be too complicated.
Both of the packages you have listed look good.