Skip to content

Commit

Permalink
Revert "feat: small speed up to processing bluez passive data"
Browse files Browse the repository at this point in the history
This reverts commit b858d95.
  • Loading branch information
bdraco committed Aug 9, 2023
1 parent 7352d08 commit d542f25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/dbus_fast/message_bus.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ cdef object assert_bus_name_valid

cdef _expects_reply(Message msg)

cdef _swallow_unexpected_reply(Message msg)

cdef class SendReply:

cdef object _bus
Expand Down
12 changes: 3 additions & 9 deletions src/dbus_fast/message_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@


def _expects_reply(msg: _Message) -> bool:
"""Whether a message expects a reply."""
return not (msg.flags.value & NO_REPLY_EXPECTED_VALUE)


def _swallow_unexpected_reply(msg: _Message) -> None:
"""Swallow a reply if it's not expected."""


class SendReply:
"""A context manager to send a reply to a message."""

Expand All @@ -55,7 +50,8 @@ def __enter__(self):
return self

def __call__(self, reply: Message) -> None:
self._bus.send(reply)
if _expects_reply(self._msg):
self._bus.send(reply)

def _exit(
self,
Expand Down Expand Up @@ -859,11 +855,9 @@ def _process_message(self, msg: _Message) -> None:
if msg.message_type is MESSAGE_TYPE_CALL:
if not handled:
handler = self._find_message_handler(msg)
if not _expects_reply(msg):
handler(msg, _swallow_unexpected_reply)
return

send_reply = SendReply(self, msg)

with send_reply:
if handler:
handler(msg, send_reply)
Expand Down

0 comments on commit d542f25

Please sign in to comment.