Skip to content

Commit

Permalink
feat: avoid enum dunder overhead in message_bus calls (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Dec 9, 2022
1 parent 19c711d commit b3c7d51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/dbus_fast/aio/message_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging
import socket
import sys
import traceback
from collections import deque
from copy import copy
from typing import Any, Optional
Expand All @@ -14,7 +13,6 @@
from asyncio import timeout as asyncio_timeout

from .. import introspection as intr
from .._private.unmarshaller import Unmarshaller
from ..auth import Authenticator, AuthExternal
from ..constants import (
BusType,
Expand All @@ -31,6 +29,8 @@
from .message_reader import build_message_reader
from .proxy_object import ProxyObject

NO_REPLY_EXPECTED_VALUE = MessageFlag.NO_REPLY_EXPECTED.value


def _future_set_exception(fut: asyncio.Future, exc: Exception) -> None:
if fut is not None and not fut.done():
Expand Down Expand Up @@ -351,7 +351,7 @@ async def call(self, msg: Message) -> Optional[Message]:
- :class:`Exception` - If a connection error occurred.
"""
if (
msg.flags & MessageFlag.NO_REPLY_EXPECTED
msg.flags.value & NO_REPLY_EXPECTED_VALUE
or msg.message_type is not MessageType.METHOD_CALL
):
await self.send(msg)
Expand Down
4 changes: 3 additions & 1 deletion src/dbus_fast/aio/proxy_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
if TYPE_CHECKING:
from .message_bus import MessageBus as AioMessageBus

NO_REPLY_EXPECTED_VALUE = MessageFlag.NO_REPLY_EXPECTED.value


class ProxyInterface(BaseProxyInterface):
"""A class representing a proxy to an interface exported on the bus by
Expand Down Expand Up @@ -100,7 +102,7 @@ async def method_fn(
)
)

if flags & MessageFlag.NO_REPLY_EXPECTED:
if flags is not None and flags.value & NO_REPLY_EXPECTED_VALUE:
return None

BaseProxyInterface._check_method_return(msg, intr_method.out_signature)
Expand Down

0 comments on commit b3c7d51

Please sign in to comment.