From 7e0f7ffd49f3298fa04809b798c9f111c0d71cf3 Mon Sep 17 00:00:00 2001 From: mulhern Date: Sun, 25 Jan 2026 18:54:12 -0500 Subject: [PATCH] Allow passing timeout value to a generated D-Bus function This grants the flexibility to override the default value established when the class was built with a value specific to this method. Signed-off-by: mulhern --- src/dbus_python_client_gen/_invokers.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/dbus_python_client_gen/_invokers.py b/src/dbus_python_client_gen/_invokers.py index f5c1d96..54c3f44 100644 --- a/src/dbus_python_client_gen/_invokers.py +++ b/src/dbus_python_client_gen/_invokers.py @@ -28,7 +28,7 @@ def prop_builder( - interface_name: str, properties: Sequence[ET.Element], timeout: int + interface_name: str, properties: Sequence[ET.Element], default_timeout: int ) -> Callable[[MutableMapping[str, Type]], None]: """ Returns a function that builds a property interface based on arguments. @@ -51,7 +51,7 @@ def prop_builder( :param str interface_name: the interface to which these properties belong :param properties: iterable of interface specifications for each property :type properties: iterable of xml.element.ElementTree.Element - :param int timeout: the dbus method timeout, -1 is the libdbus default ~25s. + :param int defaul_timeout: the D-Bus timeout, -1 is the libdbus default ~25s :raises DPClientGenerationError: """ @@ -63,7 +63,9 @@ def build_property_getter(name: str) -> Callable[[ProxyObject], Any]: :param str name: the name of the property """ - def dbus_func(proxy_object: ProxyObject) -> Any: + def dbus_func( + proxy_object: ProxyObject, *, timeout: int = default_timeout + ) -> Any: """ The property getter. @@ -108,7 +110,9 @@ def build_property_setter( fmt_str % (signature, name, interface_name) ) from err - def dbus_func(proxy_object: ProxyObject, value: Any) -> None: + def dbus_func( + proxy_object: ProxyObject, value: Any, *, timeout: int = default_timeout + ) -> None: """ The property setter. @@ -243,7 +247,7 @@ class has up to two static methods, a Get method if the property is def method_builder( - interface_name: str, methods: Sequence[ET.Element], timeout: int + interface_name: str, methods: Sequence[ET.Element], default_timeout: int ) -> Callable[[MutableMapping[str, Callable]], None]: """ Returns a function that builds a method interface based on 'spec'. @@ -262,7 +266,7 @@ def method_builder( :param str interface_name: name the interface to which the methods belong :param methods: the iterable of interface specification for each method :type methods: iterator of xml.element.ElementTree.Element - :param int timeout: the dbus method timeout, -1 is the libdbus default ~25s. + :param int default_timeout: D-Bus timeout, -1 is the libdbus default ~25s. :raises DPClientGenerationError: """ @@ -309,7 +313,12 @@ def build_method( ) from err arg_names_set = frozenset(arg_names) - def dbus_func(proxy_object: ProxyObject, func_args: Mapping[str, Any]) -> Any: + def dbus_func( + proxy_object: ProxyObject, + func_args: Mapping[str, Any], + *, + timeout=default_timeout, + ) -> Any: """ The method proper. @@ -417,7 +426,7 @@ def make_class(name: str, spec: ET.Element, timeout: int = -1) -> Type: :param str name: the name of the class. :param spec: the interface specification :type spec: xml.element.ElementTree.Element - :param int timeout: dbus timeout for method(s), -1 is libdbus default ~25s. + :param int timeout: D-Bus timeout, -1 is libdbus default ~25s :returns: the constructed class :rtype: type """