You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: add D-Bus signals to blocking API #95
It would be nice to add signals to the blocking API with something like .register() to the blocking API for the async framework out there that do not rely on asyncio, e.g. gevent.
Not entirely sure if it can be viable even with libraries like gevent.
To avoid blocking the server all requests spawn a separated asyncio tasks attached to a messages. The tasks can then complete on their own without having the server to wait for each response.
The blocking functions will have to wait until they complete which forces the server to complete them one by one.
Greenlets could work but currently the D-Bus message handling is implemented in C with no way to overwrite it from Python.
In the future if you wanted to integrate with gevent you would need to do following steps:
Integrate the bus with the gevent loop. The bus can provide the file descriptor that needs to monitored for read and write events. When bus signals its ready to process events the gevent must call the process method of the bus.
Overwrite how the D-Bus <-> Python dispatching works to replace all blocking functions with gevent pseudo blocking analogues.
For example, listening on signals could be implemented using the gevent.queue and callbacks from libsystemd.
However, these are ideas for a far future when the low-level API will be published.
@christophehenry could you describe your exact use case? Do you want to listen to single signal in a blocking way or do you want to register multiple callbacks and wait on them to execute? Or do you want to integrate python-sdbus with gevent so that each green thread can listen on a single signal?
Activity
igo95862 commentedon Feb 24, 2025
Hello @christophehenry
Not entirely sure if it can be viable even with libraries like gevent.
To avoid blocking the server all requests spawn a separated asyncio tasks attached to a messages. The tasks can then complete on their own without having the server to wait for each response.
The blocking functions will have to wait until they complete which forces the server to complete them one by one.
christophehenry commentedon Feb 24, 2025
By server, you mean D-Bus? Don't Greenlets perform the same job as asyncio tasks? How about Python threads? Could it work?
igo95862 commentedon Feb 24, 2025
Greenlets could work but currently the D-Bus message handling is implemented in C with no way to overwrite it from Python.
In the future if you wanted to integrate with gevent you would need to do following steps:
For example, listening on signals could be implemented using the
gevent.queueand callbacks fromlibsystemd.However, these are ideas for a far future when the low-level API will be published.
igo95862 commentedon Apr 12, 2025
@christophehenry could you describe your exact use case? Do you want to listen to single signal in a blocking way or do you want to register multiple callbacks and wait on them to execute? Or do you want to integrate python-sdbus with gevent so that each green thread can listen on a single signal?
christophehenry commentedon Apr 12, 2025
I guess be able to listen to a signal in a blocking way may be useful in some case. But my own need only concerns a gevent integration.