- 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
-