From 38e15a82c0d359e2c94a1b5aac17db63a737a1cd Mon Sep 17 00:00:00 2001 From: Ji-Wei Date: Sat, 3 Sep 2016 11:44:13 +0800 Subject: [PATCH] Raise NotImplementedError instead of NotImplemented NotImplementedError is the name of the exception (https://docs.python.org/2/library/exceptions.html). NotImplemented is the name of a constant (https://docs.python.org/2/library/constants.html). >>> raise NotImplemented() Traceback (most recent call last): File "", line 1, in raise NotImplemented() TypeError: 'NotImplementedType' object is not callable >>> raise NotImplementedError() Traceback (most recent call last): File "", line 1, in raise NotImplementedError() NotImplementedError This patch fix it. Change-Id: If4ea80c9e72478a9547c0c125d7cc1a5a1eccd1f Closes-Bug: #1339855 --- solar/dblayer/locking.py | 2 +- solar/orchestration/executors/base.py | 8 ++++---- solar/orchestration/workers/scheduler.py | 2 +- solar/orchestration/workers/subscription.py | 2 +- solar/orchestration/workers/tasks.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/solar/dblayer/locking.py b/solar/dblayer/locking.py index f293f0af..d17cdc02 100644 --- a/solar/dblayer/locking.py +++ b/solar/dblayer/locking.py @@ -130,7 +130,7 @@ class _Lock(object): @classmethod def _acquire(cls, uid, identity): - raise NotImplemented( + raise NotImplementedError( 'Different strategies for handling collisions') @classmethod diff --git a/solar/orchestration/executors/base.py b/solar/orchestration/executors/base.py index 99d62af1..08f764a7 100644 --- a/solar/orchestration/executors/base.py +++ b/solar/orchestration/executors/base.py @@ -34,18 +34,18 @@ class Executor(object): self.worker._executor = self def register_task(self, ctxt): - raise NotImplemented( + raise NotImplementedError( 'Register task should be implemented' ' to support task interruption.') def register_timeout(self, timeout, callable_): - raise NotImplemented( + raise NotImplementedError( 'Should be implemented to propagate errors by timeout') def kill(self, task_id, exc): - raise NotImplemented( + raise NotImplementedError( 'Kill should be implemented' ' to support task interruption.') def run(self): - raise NotImplemented() + raise NotImplementedError() diff --git a/solar/orchestration/workers/scheduler.py b/solar/orchestration/workers/scheduler.py index ec9a5919..f6e55886 100644 --- a/solar/orchestration/workers/scheduler.py +++ b/solar/orchestration/workers/scheduler.py @@ -137,7 +137,7 @@ class Scheduler(base.Worker): def _configure_timeout(self, ctxt, timeout): if not hasattr(self._executor, 'register_timeout'): - raise NotImplemented('Timeout is not supported') + raise NotImplementedError('Timeout is not supported') self._executor.register_timeout( timeout, partial(self.update_next, ctxt, diff --git a/solar/orchestration/workers/subscription.py b/solar/orchestration/workers/subscription.py index 373314d8..b5be38f1 100644 --- a/solar/orchestration/workers/subscription.py +++ b/solar/orchestration/workers/subscription.py @@ -33,7 +33,7 @@ class SubControl(object): self.add_subscriber(sub, 'before') def add_subscriber(self, sub, event): - raise NotImplemented() + raise NotImplementedError() class FuncSubControl(SubControl): diff --git a/solar/orchestration/workers/tasks.py b/solar/orchestration/workers/tasks.py index dbf58818..8d24d50f 100644 --- a/solar/orchestration/workers/tasks.py +++ b/solar/orchestration/workers/tasks.py @@ -1,4 +1,4 @@ -# Copyright 2015 Mirantis, Inc. + # Copyright 2015 Mirantis, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -44,6 +44,6 @@ class Tasks(base.Worker): def kill(self, ctxt, task_id): log.debug('Received kill request for task_id %s', task_id) if not hasattr(self._executor, 'kill'): - raise NotImplemented( + raise NotImplementedError( 'Current executor doesnt support interruping tasks') self._executor.kill(task_id, ExecutionTimeout)