Skip to content

Commit 9fc1661

Browse files
committed
Allow passing timeout value to generated function
If a value is passed in, it may be used to override the default value that was used when the function was built. Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 60eef6d commit 9fc1661

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/dbus_python_client_gen/_invokers.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def build_property_getter(name: str) -> Callable[[ProxyObject], Any]:
6363
:param str name: the name of the property
6464
"""
6565

66-
def dbus_func(proxy_object: ProxyObject) -> Any:
66+
def dbus_func(
67+
proxy_object: ProxyObject, *, timeout: int = default_timeout
68+
) -> Any:
6769
"""
6870
The property getter.
6971
@@ -74,7 +76,7 @@ def dbus_func(proxy_object: ProxyObject) -> Any:
7476
interface_name,
7577
name,
7678
dbus_interface=dbus.PROPERTIES_IFACE,
77-
timeout=default_timeout,
79+
timeout=timeout,
7880
)
7981
except dbus.DBusException as err: # pragma: no cover
8082
err_msg = (
@@ -108,7 +110,9 @@ def build_property_setter(
108110
fmt_str % (signature, name, interface_name)
109111
) from err
110112

111-
def dbus_func(proxy_object: ProxyObject, value: Any) -> None:
113+
def dbus_func(
114+
proxy_object: ProxyObject, value: Any, *, timeout: int = default_timeout
115+
) -> None:
112116
"""
113117
The property setter.
114118
@@ -132,7 +136,7 @@ def dbus_func(proxy_object: ProxyObject, value: Any) -> None:
132136
name,
133137
arg,
134138
dbus_interface=dbus.PROPERTIES_IFACE,
135-
timeout=default_timeout,
139+
timeout=timeout,
136140
)
137141
except dbus.DBusException as err: # pragma: no cover
138142
err_msg = (
@@ -309,7 +313,12 @@ def build_method(
309313
) from err
310314
arg_names_set = frozenset(arg_names)
311315

312-
def dbus_func(proxy_object: ProxyObject, func_args: Mapping[str, Any]) -> Any:
316+
def dbus_func(
317+
proxy_object: ProxyObject,
318+
func_args: Mapping[str, Any],
319+
*,
320+
timeout=default_timeout,
321+
) -> Any:
313322
"""
314323
The method proper.
315324
@@ -355,9 +364,7 @@ def dbus_func(proxy_object: ProxyObject, func_args: Mapping[str, Any]) -> Any:
355364
) # pragma: no cover
356365

357366
try: # pragma: no cover
358-
return dbus_method(
359-
*xformed_args, signature=signature, timeout=default_timeout
360-
)
367+
return dbus_method(*xformed_args, signature=signature, timeout=timeout)
361368
except dbus.DBusException as err: # pragma: no cover
362369
arg_str = ", ".join(repr(arg) for arg in xformed_args)
363370
err_msg = (

0 commit comments

Comments
 (0)