question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Evaluate switching from txdbus to other Python DBus package

See original GitHub issue

Description

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:

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:closed
  • Created 3 years ago
  • Comments:34 (22 by maintainers)

github_iconTop GitHub Comments

4reactions
cspenskycommented, Jan 22, 2021

@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.

2reactions
dlechcommented, Jul 1, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found