def test_RemoveReader_ResultsInReaderNoLongerBeingSelectedOrWiredIn(self): "main - Sending a remove reader message unwires/links a component, and also removes it's selectable from the readers list" MOCKSELECTORMODULE = MockSelect(results=[ ([], [], [] )]) SELECTORMODULE.select = MOCKSELECTORMODULE S = Selector() S.activate() for i in xrange(100): S.next() D = Axon.Component.component() dummyservice = (D, "inbox") S._deliver(newReader(S,( dummyservice, "LOOKINGFORTHIS") ),"notify") S._deliver(removeReader(S,"LOOKINGFORTHIS"),"notify") for i in xrange(100): S.next(); try: S.postoffice.next() except: pass self.assert_( D.inboxes["inbox"] == [] )
def closeSocket(self, shutdownMessage): """\ Respond to a socketShutdown message by closing the socket. Sends a removeReader and removeWriter message to the selectorComponent. Sends a shutdownCSA(self, theCSA) message to "protocolHandlerSignal" outbox. """ theComponent,sock = shutdownMessage.caller, shutdownMessage.message sock.close() # tell the selector about it shutting down self.send(removeReader(theComponent, theComponent.socket), "_selectorSignal") self.send(removeWriter(theComponent, theComponent.socket), "_selectorSignal") # tell protocol handlers self.send(_ki.shutdownCSA(self, theComponent), "protocolHandlerSignal")# "signal") # Delete the child component self.removeChild(theComponent)
def test_RemoveReader_ResultsInReaderNoLongerBeingSelectedOrWiredIn(self): "main - Sending a remove reader message unwires/links a component, and also removes it's selectable from the readers list" MOCKSELECTORMODULE = MockSelect(results=[([], [], [])]) SELECTORMODULE.select = MOCKSELECTORMODULE S = Selector() S.activate() for i in xrange(100): S.next() D = Axon.Component.component() dummyservice = (D, "inbox") S._deliver(newReader(S, (dummyservice, "LOOKINGFORTHIS")), "notify") S._deliver(removeReader(S, "LOOKINGFORTHIS"), "notify") for i in xrange(100): S.next() try: S.postoffice.next() except: pass self.assert_(D.inboxes["inbox"] == [])
def closeSocket(self, shutdownMessage): """\ Respond to a socketShutdown message by closing the socket. Sends a removeReader and removeWriter message to the selectorComponent. Sends a shutdownCSA(self, theCSA) message to "protocolHandlerSignal" outbox. """ theComponent, sock = shutdownMessage.caller, shutdownMessage.message sock.close() # tell the selector about it shutting down self.send(removeReader(theComponent, theComponent.socket), "_selectorSignal") self.send(removeWriter(theComponent, theComponent.socket), "_selectorSignal") # tell protocol handlers self.send(_ki.shutdownCSA(self, theComponent), "protocolHandlerSignal") # "signal") # Delete the child component self.removeChild(theComponent)
self.recv("stdoutready") try: Y = os.read(x.stdout.fileno(), 10) while Y: self.send(Y, "outbox") Y = os.read(x.stdout.fileno(), 10) print self.name, "Mighty Floogly" except OSError, e: continue except: break yield 1 # remove now closed file handles from the selector, so it doesn't stay # upset self.send(removeReader(self, (x.stderr)), "selector") self.send(removeReader(self, (x.stdout)), "selector") self.send(removeWriter(self, (x.stdin)), "selector") print self.name, "sending shutdown" if not shutdownMessage: print self.name, "new signal" self.send(Axon.Ipc.producerFinished(), "signal") print self.name, "...sent" else: print self.name, "old signal" self.send(shutdownMessage, "signal") # \ # print "...sent" # self.send(shutdown(), "selectorsignal")