Skip to content

Commit ec7e8db

Browse files
committed
Rename timeout to default_timeout
We want to add the flexibility to override with a different timeout for individual methods. Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 61e18ac commit ec7e8db

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

src/dbus_python_client_gen/_invokers.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
def prop_builder(
31-
interface_name: str, properties: Sequence[ET.Element], timeout: int
31+
interface_name: str, properties: Sequence[ET.Element], default_timeout: int
3232
) -> Callable[[MutableMapping[str, Type]], None]:
3333
"""
3434
Returns a function that builds a property interface based on arguments.
@@ -51,7 +51,7 @@ def prop_builder(
5151
:param str interface_name: the interface to which these properties belong
5252
:param properties: iterable of interface specifications for each property
5353
:type properties: iterable of xml.element.ElementTree.Element
54-
:param int timeout: the dbus method timeout, -1 is the libdbus default ~25s.
54+
:param int defaul_timeout: the dbus timeout, -1 is the libdbus default ~25s
5555
5656
:raises DPClientGenerationError:
5757
"""
@@ -74,7 +74,7 @@ def dbus_func(proxy_object: ProxyObject) -> Any:
7474
interface_name,
7575
name,
7676
dbus_interface=dbus.PROPERTIES_IFACE,
77-
timeout=timeout,
77+
timeout=default_timeout,
7878
)
7979
except dbus.DBusException as err: # pragma: no cover
8080
err_msg = (
@@ -132,7 +132,7 @@ def dbus_func(proxy_object: ProxyObject, value: Any) -> None:
132132
name,
133133
arg,
134134
dbus_interface=dbus.PROPERTIES_IFACE,
135-
timeout=timeout,
135+
timeout=default_timeout,
136136
)
137137
except dbus.DBusException as err: # pragma: no cover
138138
err_msg = (
@@ -243,7 +243,7 @@ class has up to two static methods, a Get method if the property is
243243

244244

245245
def method_builder(
246-
interface_name: str, methods: Sequence[ET.Element], timeout: int
246+
interface_name: str, methods: Sequence[ET.Element], default_timeout: int
247247
) -> Callable[[MutableMapping[str, Callable]], None]:
248248
"""
249249
Returns a function that builds a method interface based on 'spec'.
@@ -262,7 +262,7 @@ def method_builder(
262262
:param str interface_name: name the interface to which the methods belong
263263
:param methods: the iterable of interface specification for each method
264264
:type methods: iterator of xml.element.ElementTree.Element
265-
:param int timeout: the dbus method timeout, -1 is the libdbus default ~25s.
265+
:param int default_timeout: D-Bus timeout, -1 is the libdbus default ~25s.
266266
267267
:raises DPClientGenerationError:
268268
"""
@@ -355,7 +355,9 @@ def dbus_func(proxy_object: ProxyObject, func_args: Mapping[str, Any]) -> Any:
355355
) # pragma: no cover
356356

357357
try: # pragma: no cover
358-
return dbus_method(*xformed_args, signature=signature, timeout=timeout)
358+
return dbus_method(
359+
*xformed_args, signature=signature, timeout=default_timeout
360+
)
359361
except dbus.DBusException as err: # pragma: no cover
360362
arg_str = ", ".join(repr(arg) for arg in xformed_args)
361363
err_msg = (
@@ -409,15 +411,15 @@ def builder(namespace: MutableMapping[str, Callable]) -> None:
409411
return builder
410412

411413

412-
def make_class(name: str, spec: ET.Element, timeout: int = -1) -> Type:
414+
def make_class(name: str, spec: ET.Element, default_timeout: int = -1) -> Type:
413415
"""
414416
Make a class, name, from the given spec.
415417
The class defines static properties and methods according to the spec.
416418
417419
:param str name: the name of the class.
418420
:param spec: the interface specification
419421
:type spec: xml.element.ElementTree.Element
420-
:param int timeout: dbus timeout for method(s), -1 is libdbus default ~25s.
422+
:param int default_timeout: D-Bus timeout, -1 is libdbus default ~25s
421423
:returns: the constructed class
422424
:rtype: type
423425
"""
@@ -428,9 +430,11 @@ def make_class(name: str, spec: ET.Element, timeout: int = -1) -> Type:
428430
raise DPClientGenerationError("No name attribute found for interface") from err
429431

430432
method_builder_arg = method_builder(
431-
interface_name, spec.findall("./method"), timeout
433+
interface_name, spec.findall("./method"), default_timeout
434+
)
435+
prop_builder_arg = prop_builder(
436+
interface_name, spec.findall("./property"), default_timeout
432437
)
433-
prop_builder_arg = prop_builder(interface_name, spec.findall("./property"), timeout)
434438

435439
def builder(namespace: MutableMapping[str, Type]) -> None:
436440
"""

0 commit comments

Comments
 (0)