

def call_hook(self, hook_name, **kwargs):
    'Call a hook function'
    hook_kwargs = {
        'watcher': self,
        'arbiter': self.arbiter,
        'hook_name': hook_name,
    }
    hook_kwargs.update(kwargs)
    if (hook_name in self.hooks):
        try:
            result = self.hooks[hook_name](**hook_kwargs)
            self.notify_event('hook_success', {
                'name': hook_name,
                'time': time.time(),
            })
        except Exception as error:
            logger.exception(('Hook %r failed' % hook_name))
            result = (hook_name in self.ignore_hook_failure)
            self.notify_event('hook_failure', {
                'name': hook_name,
                'time': time.time(),
                'error': str(error),
            })
        return result
    else:
        return True

dataset/ETHPy150Open circus-tent/circus/circus/watcher.py Watcher.call_hook/original