Skip to content

Feature request: add D-Bus signals to blocking API #95

Open

Description

@christophehenry

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.

Activity

  1. igo95862 commented on Feb 24, 2025

    @igo95862
    Collaborator

    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.

  2. christophehenry commented on Feb 24, 2025

    @christophehenry
    Author

    By server, you mean D-Bus? Don't Greenlets perform the same job as asyncio tasks? How about Python threads? Could it work?

  3. igo95862 commented on Feb 24, 2025

    @igo95862
    Collaborator

    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:

    1. 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.
    2. 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.

  4. igo95862 commented on Apr 12, 2025

    @igo95862
    Collaborator

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

  5. christophehenry commented on Apr 12, 2025

    @christophehenry
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions