diff --git a/src/dbus_fast/message_bus.pxd b/src/dbus_fast/message_bus.pxd index 723d701..9c88836 100644 --- a/src/dbus_fast/message_bus.pxd +++ b/src/dbus_fast/message_bus.pxd @@ -12,6 +12,9 @@ cdef object MessageFlag cdef object MESSAGE_TYPE_CALL cdef object MESSAGE_TYPE_SIGNAL cdef cython.uint NO_REPLY_EXPECTED_VALUE +cdef object NONE +cdef object NO_REPLY_EXPECTED + cdef object BLOCK_UNEXPECTED_REPLY cdef object assert_object_path_valid cdef object assert_bus_name_valid diff --git a/src/dbus_fast/message_bus.py b/src/dbus_fast/message_bus.py index 55a6fe0..0e9bf1a 100644 --- a/src/dbus_fast/message_bus.py +++ b/src/dbus_fast/message_bus.py @@ -29,6 +29,8 @@ from .validators import assert_bus_name_valid, assert_object_path_valid MESSAGE_TYPE_CALL = MessageType.METHOD_CALL MESSAGE_TYPE_SIGNAL = MessageType.SIGNAL NO_REPLY_EXPECTED_VALUE = MessageFlag.NO_REPLY_EXPECTED.value +NO_REPLY_EXPECTED = MessageFlag.NO_REPLY_EXPECTED +NONE = MessageFlag.NONE _LOGGER = logging.getLogger(__name__) @@ -37,6 +39,11 @@ _Message = Message def _expects_reply(msg: _Message) -> bool: """Whether a message expects a reply.""" + if msg.flags is NO_REPLY_EXPECTED: + return False + if msg.flags is NONE: + return True + # Slow check for NO_REPLY_EXPECTED flag_value = msg.flags.value return not (flag_value & NO_REPLY_EXPECTED_VALUE) @@ -734,19 +741,19 @@ class BaseMessageBus: if not msg.serial: msg.serial = self.next_serial() - no_reply_expected = not _expects_reply(msg) + reply_expected = _expects_reply(msg) # Make sure the return reply handler is installed # before sending the message to avoid a race condition # where the reply is lost in case the backend can # send it right away. - if not no_reply_expected: + if reply_expected: self._method_return_handlers[msg.serial] = partial( self._reply_notify, msg, callback ) self.send(msg) - if no_reply_expected: + if not reply_expected: callback(None, None) @staticmethod @@ -901,7 +908,7 @@ class BaseMessageBus: def _find_message_handler( self, msg: _Message ) -> Optional[Callable[[Message, Callable[[Message], None]], None]]: - if msg.interface.startswith("org.freedesktop.DBus."): + if "org.freedesktop.DBus." in msg.interface: if ( msg.interface == "org.freedesktop.DBus.Introspectable" and msg.member == "Introspect" diff --git a/src/dbus_fast/service.pxd b/src/dbus_fast/service.pxd index 40a2ad3..6a2d637 100644 --- a/src/dbus_fast/service.pxd +++ b/src/dbus_fast/service.pxd @@ -10,7 +10,7 @@ cdef class _Method: cdef public str name cdef public object fn - cdef public object disabled + cdef public bint disabled cdef public object introspection cdef public str in_signature cdef public str out_signature