Event-loop-friendly receive_message() call

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Sun Jan 21 01:23:21 UTC 2018


I have added a new feature to DBussy <https://github.com/ldo/dbussy>,
my Python binding for libdbus, namely a call to read incoming messages
from a connection in an event-loop-friendly way, with an optional
timeout.

First, you enable the types of messages you want to be automatically
queued for such reception on a dbussy.Connection object, e.g.

    conn.enable_receive_message \
      (
        {DBUS.MESSAGE_TYPE_METHOD_CALL, DBUS.MESSAGE_TYPE_SIGNAL}
      )

Then you can wait for the next message in a loop like

    while True :
        message = await conn.receive_message_async()
        ... process message ...
    #end while

For a more detailed example, see the “signal_listener_queued” script
here <https://github.com/ldo/dbussy_examples>.


More information about the dbus mailing list