Commit e7beaa02 authored by Iustin Pop's avatar Iustin Pop
Browse files

burnin: move decorators out of classes



Similar to commit c881c5, we move the decorators out of classes, such
that they become simple functions instead of methods. This more clean,
since only the wrapped functions need to be methods/have access to
‘self’.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarOlivier Tharan <olive@google.com>
parent e2e10467
......@@ -201,6 +201,39 @@ OPTIONS = [
ARGUMENTS = [cli.ArgInstance(min=1)]
def _DoCheckInstances(fn):
"""Decorator for checking instances.
"""
def wrapper(self, *args, **kwargs):
val = fn(self, *args, **kwargs)
for instance in self.instances:
self._CheckInstanceAlive(instance)
return val
return wrapper
def _DoBatch(retry):
"""Decorator for possible batch operations.
Must come after the _DoCheckInstances decorator (if any).
@param retry: whether this is a retryable batch, will be
passed to StartBatch
"""
def wrap(fn):
def batched(self, *args, **kwargs):
self.StartBatch(retry)
val = fn(self, *args, **kwargs)
self.CommitQueue()
return val
return batched
return wrap
class Burner(object):
"""Burner class."""
......@@ -350,37 +383,6 @@ class Burner(object):
raise BurninFailure()
return results
def _DoCheckInstances(fn):
"""Decorator for checking instances.
"""
def wrapper(self, *args, **kwargs):
val = fn(self, *args, **kwargs)
for instance in self.instances:
self._CheckInstanceAlive(instance)
return val
return wrapper
def _DoBatch(retry):
"""Decorator for possible batch operations.
Must come after the _DoCheckInstances decorator (if any).
@param retry: whether this is a retryable batch, will be
passed to StartBatch
"""
def wrap(fn):
def batched(self, *args, **kwargs):
self.StartBatch(retry)
val = fn(self, *args, **kwargs)
self.CommitQueue()
return val
return batched
return wrap
def ParseOptions(self):
"""Parses the command line options.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment