Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: avoid enum dunder overhead in message_bus calls #187

Merged
merged 6 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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