def main(self): not_done = True i = 0 ilist = [] while not_done: i += 1 print str(i) if not i % 3: ilist.append(str(i)) self.log.writelines(ilist) ilist = [] else: ilist.append(str(i)) if i == 50: self.log.writelines(ilist) self.log.flush() not_done = False yield 1 self.send(Ipc.shutdownMicroprocess(), 'signal') self.send(Ipc.shutdownMicroprocess(), 'signal-logger')
def shutdown(self): """Sends terminatory signals to the wrapped component, and shut down the componentWrapper. will warn if the shutdown took too long to confirm in action.""" # TODO - what if the wrapped component has no control box? if self.alive: self.put(Ipc.shutdown(), "control") # legacy support. self.put(Ipc.producerFinished(), "control") # some components only honour this one self.put(Ipc.shutdownMicroprocess(), "control") # should be last, this is what we honour else: raise AttributeError("shutdown was previously called, or we were never activated.") self.inputComponent.isDead.wait(1) if not self.inputComponent.isDead.isSet(): # we timed out instead of someone else setting the flag warnings.warn("Timed out waiting on shutdown confirmation, may not be dead.") self.alive = False