diff --git a/secop/modules.py b/secop/modules.py index 5746378..a8d9ec6 100644 --- a/secop/modules.py +++ b/secop/modules.py @@ -257,6 +257,9 @@ class Module(HasAccessibles): self.name = name self.valueCallbacks = {} self.errorCallbacks = {} + self.earlyInitDone = False + self.initModuleDone = False + self.startModuleDone = False errors = [] # handle module properties @@ -523,11 +526,12 @@ class Module(HasAccessibles): return False def earlyInit(self): - # may be overriden in derived classes to init stuff - self.log.debug('empty %s.earlyInit()' % self.__class__.__name__) + """initialise module with stuff to be done before all modules are created""" + self.earlyInitDone = True def initModule(self): - self.log.debug('empty %s.initModule()' % self.__class__.__name__) + """initialise module with stuff to be done after all modules are created""" + self.initModuleDone = True def pollOneParam(self, pname): """poll parameter with proper error handling""" @@ -569,7 +573,11 @@ class Module(HasAccessibles): has finished its initial work might return a timeout value, if different from default """ - mkthread(self.writeInitParams, started_callback) + if self.writeDict: + mkthread(self.writeInitParams, started_callback) + else: + started_callback() + self.startModuleDone = True class Readable(Module): diff --git a/secop/server.py b/secop/server.py index 8f49de5..4fa85b3 100644 --- a/secop/server.py +++ b/secop/server.py @@ -281,6 +281,8 @@ class Server: modobj.pollerClass.add_to_table(poll_table, modobj) # also call earlyInit on the modules modobj.earlyInit() + if not modobj.earlyInitDone: + modobj.log.warning('missing supercall to earlyInit') # handle attached modules for modname, modobj in self.modules.items(): @@ -296,6 +298,8 @@ class Server: for modname, modobj in self.modules.items(): try: modobj.initModule() + if not modobj.initModuleDone: + modobj.log.warning('missing supercall to initModule') except Exception as e: if failure_traceback is None: failure_traceback = traceback.format_exc() @@ -319,6 +323,8 @@ class Server: event = threading.Event() # startModule must return either a timeout value or None (default 30 sec) timeout = modobj.startModule(started_callback=event.set) or 30 + if not modobj.startModuleDone: + modobj.log.warning('missing supercall to startModule') start_events.append((time.time() + timeout, 'module %s' % modname, event)) for poller in poll_table.values(): event = threading.Event()