Event-loop-friendly receive_message() call

Lawrence D'Oliveiro <ldo-kC51rjc0cqs1dNLGKZg6taU/[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Organization Geek Central
Message-ID <[email protected]>
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>.
_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.