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_RemoveWriter_ResultsInWriterNoLongerBeingSelectedOrWiredIn(self): "main - Sending a remove writer message unwires/links a component, and also removes it's selectable from the writers 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(newWriter(S,( dummyservice, "LOOKINGFORTHIS") ),"notify") S._deliver(removeWriter(S,"LOOKINGFORTHIS"),"notify") for i in xrange(100): S.next(); try: S.postoffice.next() except: pass print self.assert_( D.inboxes["inbox"] == [] )
def test_RemoveWriter_ResultsInWriterNoLongerBeingSelectedOrWiredIn(self): "main - Sending a remove writer message unwires/links a component, and also removes it's selectable from the writers 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(newWriter(S, (dummyservice, "LOOKINGFORTHIS")), "notify") S._deliver(removeWriter(S, "LOOKINGFORTHIS"), "notify") for i in xrange(100): S.next() try: S.postoffice.next() except: pass print 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)
if len(Y) > 0: self.send(Y, "outbox") # No particular plans for stderr except OSError, e: print self.name, "Mighty Jibble", len(self.inboxes["inbox"]), len(writeBuffer) # stdout wasn't ready. Let's send through a newReader request stderr_ready = 0 self.send(newReader(self, ((self, "stderrready"), x.stderr)), "selector") except: print self.name, "Unexpected error whilst trying to read stderr:" print sys.exc_info()[0] pass if self.dataReady("control"): shutdownMessage = self.recv("control") self.send(removeWriter(self, (x.stdin)), "selector") yield 1 x.stdin.close() yield 1 print self.name, "UnixPipe finishing up" while self.dataReady("stdoutready"): print self.name, "flushing" 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: