From c8209d01f9ddf4c6670caee08073924cb33e447f Mon Sep 17 00:00:00 2001 From: rcoh Date: Wed, 29 Dec 2010 12:43:05 -0500 Subject: setting up some more behaviors to get inherited from --- operationscore/Input.py | 7 ++++++- operationscore/SmootCoreObject.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'operationscore') diff --git a/operationscore/Input.py b/operationscore/Input.py index 62c4682..9e8841a 100644 --- a/operationscore/Input.py +++ b/operationscore/Input.py @@ -1,5 +1,6 @@ import threading,time from operationscore.SmootCoreObject import * +from logger import main_log, exception_log #Abstract class for inputs. Inheriting classes should call "respond" to raise #their event. Inheriting classes MUST define sensingLoop. Called at the #interval specified in RefreshInterval while the input is active. For example, if you are writing @@ -33,7 +34,11 @@ class Input(SmootCoreObject): except: return False def run(self): - while self.parentAlive(): + while 1: + try: + die = self.parentAlive() + except: + break time.sleep(self.argDict['RefreshInterval']/float(1000)) self.acquireLock() self.sensingLoop() diff --git a/operationscore/SmootCoreObject.py b/operationscore/SmootCoreObject.py index 9784aab..26b3fc2 100644 --- a/operationscore/SmootCoreObject.py +++ b/operationscore/SmootCoreObject.py @@ -19,7 +19,7 @@ class SmootCoreObject(threading.Thread): def releaseLock(self): self.lock.release() def className(self): - return str(self.__class__).split('.')[-1] #TODO: this doesn't work. + return self.__class__.__name__ def __setitem__(self,k, item): self.argDict[k] = item def __getitem__(self, item): -- cgit v1.2.3