taurus-org / taurus

Moved to https://gitlab.com/taurus-org/taurus
http://taurus-scada.org
43 stars 46 forks source link

__get_disk_counters should catch PermissionError #1170

Closed xoffey closed 3 years ago

xoffey commented 3 years ago

I am running taurus on a system where user programs are not allowed to access /sys/block. The result is that bzt crashes with a PermissionError exception. This occurs under Android and some cloud providers.

The offending code is in the __get_disk_counters function in montitoring.py. The current code actually catches RuntimeError. If I simply change it to catch Exception, bzt seems to work fine.

def __get_disk_counters(self):
    counters = None
    try:
        counters = psutil.disk_io_counters()
    except RuntimeError as exc:    # change to Exception here
        self.log.debug("Failed to get disk metrics: %s", exc)
    if counters is None:
        counters = psutil._common.sdiskio(0, 0, 0, 0, 0, 0)  # pylint: disable=protected-access
        # noinspection PyProtectedMember
    return counters
cpascual commented 3 years ago

Hi @xoffey , Maybe you posted on the wrong repo? I am not aware of "bzt" or __get_disk_counters existing in this taurus (this is taurus-scada.org )

xoffey commented 3 years ago

So sorry! Who knew there were multiple tauri!