]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
mgr/diskprediction_cloud: refactor timeout() decorator
authorKefu Chai <kchai@redhat.com>
Sun, 27 Oct 2019 02:00:01 +0000 (10:00 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 27 Oct 2019 02:15:09 +0000 (10:15 +0800)
commit3f56b1f3ef971d4e6123c54fdac23654bfd65cca
tree7b72dd6ffd791335bbc33161ffb0f80eea66a17b
parent3e2f997061d72e8fc75aed363234aae403594b0e
mgr/diskprediction_cloud: refactor timeout() decorator

* timeout() is never passed any parameter when being called, so let's
  remove the parameters list of "seconds" and "error_message"
* use `getattr()` instead of `hasattr()` for retrieving the
  member variable of `self`
* pass `self` to wrapper function explicitly.
* return `func()` right away.
* hardwire the error message of `TimeoutError` to "Timer expired",
  because
  - as neither errno.ETIME nor errno.ETIMEOUT is portable
  - the only caller of `TimeoutError` is `timeout()`, so there is
    no need to have the flexibility to pass a different error message
* use `wraps()` as a decorator, simpler this way.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/diskprediction_cloud/agent/__init__.py
src/pybind/mgr/diskprediction_cloud/common/__init__.py