From aee3da9f20c36cf6379d1e69e63f33a88592f6fd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 9 Sep 2022 16:57:19 -0500 Subject: [PATCH] feat: improve callback performance (#16) --- src/dbus_fast/aio/message_bus.py | 2 +- src/dbus_fast/message_bus.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dbus_fast/aio/message_bus.py b/src/dbus_fast/aio/message_bus.py index 4100b46..9c9a0d3 100644 --- a/src/dbus_fast/aio/message_bus.py +++ b/src/dbus_fast/aio/message_bus.py @@ -332,7 +332,7 @@ class MessageBus(BaseMessageBus): else: _future_set_result(future, reply) - self._call(msg, reply_handler) + self._call(msg, reply_handler, check_callback=False) await future diff --git a/src/dbus_fast/message_bus.py b/src/dbus_fast/message_bus.py index 9beb313..4d8da18 100644 --- a/src/dbus_fast/message_bus.py +++ b/src/dbus_fast/message_bus.py @@ -634,8 +634,9 @@ class BaseMessageBus: if err: raise err - def _call(self, msg, callback): - BaseMessageBus._check_callback_type(callback) + def _call(self, msg, callback, check_callback: bool = True) -> None: + if check_callback: + BaseMessageBus._check_callback_type(callback) if not msg.serial: msg.serial = self.next_serial() @@ -887,6 +888,7 @@ class BaseMessageBus: member="GetMachineId", ), reply_handler, + check_callback=False, ) def _default_get_managed_objects_handler(self, msg, send_reply): @@ -1109,6 +1111,7 @@ class BaseMessageBus: body=[self._name_owner_match_rule], ), add_match_notify, + check_callback=False, ) def _add_match_rule(self, match_rule): @@ -1142,6 +1145,7 @@ class BaseMessageBus: body=[match_rule], ), add_match_notify, + check_callback=False, ) def _remove_match_rule(self, match_rule): @@ -1180,4 +1184,5 @@ class BaseMessageBus: body=[match_rule], ), remove_match_notify, + check_callback=False, )