From 4f2b4fdd8dd851e6d62cbb7396106531e5149d06 Mon Sep 17 00:00:00 2001 From: Alexander Chadin Date: Wed, 19 Dec 2018 13:41:13 +0300 Subject: [PATCH] Remove unused modules This patch set removes "observable" and "synchronization" modules cause they aren't used by any Watcher modules so far. Change-Id: If23cdf0d3d09087919d48f50ab38b0d355c36481 --- watcher/common/observable.py | 57 ------------------------------- watcher/common/synchronization.py | 22 ------------ 2 files changed, 79 deletions(-) delete mode 100644 watcher/common/observable.py delete mode 100644 watcher/common/synchronization.py diff --git a/watcher/common/observable.py b/watcher/common/observable.py deleted file mode 100644 index 3f08185ce..000000000 --- a/watcher/common/observable.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- encoding: utf-8 -*- -# Copyright (c) 2015 b<>com -# -# 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 a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from watcher.common import synchronization - - -class Observable(synchronization.Synchronization): - def __init__(self): - super(Observable, self).__init__() - self.__observers = [] - self.changed = 0 - - def set_changed(self): - self.changed = 1 - - def clear_changed(self): - self.changed = 0 - - def has_changed(self): - return self.changed - - def register_observer(self, observer): - if observer not in self.__observers: - self.__observers.append(observer) - - def unregister_observer(self, observer): - try: - self.__observers.remove(observer) - except ValueError: - pass - - def notify(self, ctx=None, publisherid=None, event_type=None, - metadata=None, payload=None, modifier=None): - self.mutex.acquire() - try: - if not self.changed: - return - for observer in self.__observers: - if modifier != observer: - observer.update(self, ctx, metadata, publisherid, - event_type, payload) - self.clear_changed() - finally: - self.mutex.release() diff --git a/watcher/common/synchronization.py b/watcher/common/synchronization.py deleted file mode 100644 index ffeccd196..000000000 --- a/watcher/common/synchronization.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- encoding: utf-8 -*- -# Copyright (c) 2015 b<>com -# -# 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 a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import threading - - -class Synchronization(object): - def __init__(self): - self.mutex = threading.RLock()