feat: improve callback performance (#16)

This commit is contained in:
J. Nick Koston 2022-09-09 16:57:19 -05:00 committed by GitHub
parent 57d84586ab
commit aee3da9f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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,
)