from Axon.Component import component
from Axon.Ipc import producerFinished, shutdownMicroprocess, shutdown

class DataSource(component):
    def __init__(self, messages):
        super(DataSource, self).__init__()
        self.messages = messages
        
    def main(self):
        while len(self.messages) > 0:
            yield 1
            self.send(self.messages.pop(0), "outbox")
        self.send(producerFinished(), "signal")

from Axon.Component import component
from Axon.Ipc import producerFinished, shutdownMicroprocess, shutdown

class DataSource(component):
    def __init__(self, messages):
        super(DataSource, self).__init__()
        self.messages = messages
        
    def main(self):
        while len(self.messages) > 0:
            yield 1
            self.send(self.messages.pop(0), "outbox")
        yield 1
        self.send(producerFinished(), "signal")
        return

if __name__ == "__main__":
    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer

    pipeline(
        DataSource( ["hello", " ", "there", " ", "how", " ", "are", " ", "you", " ", "today\r\n", "?", "!"] ),
        ConsoleEchoer()
    ).run()

Work around a minor bug in ConsoleEchoer - yield before sending a complete message.
Work around a minor bug in ConsoleEchoer - yield before sending a
complete message.

  from Axon.Component import component
  from Axon.Ipc import producerFinished, shutdownMicroprocess, shutdown
  
  class DataSource(component):
      def __init__(self, messages):
          super(DataSource, self).__init__()
          self.messages = messages
          
      def main(self):
          while len(self.messages) > 0:
              yield 1
              self.send(self.messages.pop(0), "outbox")
+         yield 1
          self.send(producerFinished(), "signal")
+         return
  
+ if __name__ == "__main__":
+     from Kamaelia.Util.PipelineComponent import pipeline
+     from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
+ 
+     pipeline(
+         DataSource( ["hello", " ", "there", " ", "how", " ", "are", " ", "you", " ", "today\r\n", "?", "!"] ),
+         ConsoleEchoer()
+     ).run()
+ 
Work around a minor bug in ConsoleEchoer - yield before sending a complete message.
## Code Before:
from Axon.Component import component
from Axon.Ipc import producerFinished, shutdownMicroprocess, shutdown

class DataSource(component):
    def __init__(self, messages):
        super(DataSource, self).__init__()
        self.messages = messages
        
    def main(self):
        while len(self.messages) > 0:
            yield 1
            self.send(self.messages.pop(0), "outbox")
        self.send(producerFinished(), "signal")

## Instruction:
Work around a minor bug in ConsoleEchoer - yield before sending a complete message.
## Code After:
from Axon.Component import component
from Axon.Ipc import producerFinished, shutdownMicroprocess, shutdown

class DataSource(component):
    def __init__(self, messages):
        super(DataSource, self).__init__()
        self.messages = messages
        
    def main(self):
        while len(self.messages) > 0:
            yield 1
            self.send(self.messages.pop(0), "outbox")
        yield 1
        self.send(producerFinished(), "signal")
        return

if __name__ == "__main__":
    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer

    pipeline(
        DataSource( ["hello", " ", "there", " ", "how", " ", "are", " ", "you", " ", "today\r\n", "?", "!"] ),
        ConsoleEchoer()
    ).run()
