1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvmdbustest: Print messages if timeout value > 10%

We will dump some informational messages if the time to return when we
specify a timeout exceeds 10% of requested.
This commit is contained in:
Tony Asleson 2016-12-14 15:32:08 -06:00
parent a7e1f973cc
commit eacff5c189

View File

@ -16,6 +16,7 @@ from collections import OrderedDict
import dbus
import os
import sys
import time
BUS_NAME = os.getenv('LVM_DBUS_NAME', 'com.redhat.lvmdbus1')
BASE_INTERFACE = 'com.redhat.lvmdbus1'
@ -188,10 +189,15 @@ class RemoteInterface(object):
def __init__(
self, dbus_object, interface, introspect,
properties=None):
properties=None, timelimit=-1):
self.dbus_object = dbus_object
self.interface = interface
self.introspect = introspect
self.tmo = 0
if timelimit >= 0:
self.tmo = float(timelimit)
self.tmo *= 1.10
self.dbus_interface = dbus.Interface(self.dbus_object, self.interface)
self._set_props(properties)
@ -203,7 +209,19 @@ class RemoteInterface(object):
return functools.partial(self, item)
def _wrapper(self, _method_name, *args, **kwargs):
# Lets see how long a method takes to execute, in call cases we should
# return something when the time limit has been reached.
start = time.time()
result = getattr(self.dbus_interface, _method_name)(*args, **kwargs)
end = time.time()
diff = end - start
if self.tmo > 0.0:
if diff > self.tmo:
std_err_print("\n Time exceeded: %f > %f %s" %
(diff, self.tmo, _method_name))
if self.introspect:
if 'RETURN_VALUE' in self.introspect[
@ -236,13 +254,14 @@ class ClientProxy(object):
short_name = ClientProxy._intf_short_name(interface)
self.short_interface_names.append(short_name)
ro = RemoteInterface(self.dbus_object, interface, introspect,
properties)
properties, timelimit=self.tmo)
setattr(self, short_name, ro)
def __init__(self, bus, object_path, interface_prop_hash=None,
interfaces=None):
interfaces=None, timelimit=-1):
self.object_path = object_path
self.short_interface_names = []
self.tmo = timelimit
self.dbus_object = bus.get_object(
BUS_NAME, self.object_path, introspect=False)