April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.

Kamaelia.Util.OneShot

One-shot sending data

OneShot and TriggeredOneShot send a single specified item to their "outbox" outbox and immediately terminate.

TriggeredOneShot waits first for anything to arrive at its "inbox" inbox, whereas OneShot acts as soon as it is activated.

Example Usage

A way to create a component that writes data to a given filename, based on (filename,data) messages sent to its "next" inbox:

Carousel( lambda filename, data :
            Pipeline( OneShot(data),
                      SimpleFileWriter(filename),
                    ),
        )

A graphline that opens a TCP connection to myserver.com port 1500, and sends an a one off message:

Pipeline( OneShot("data to send to server"),
          TCPClient("myserver.com", 1500),
        ).run()

Shutting down a connection to myserver.com port 1500 as soon as a reply is received from the server:

Graphline( NET   = TCPClient("myserver.com", 1500),
           SPLIT = TwoWaySplitter(),
           STOP  = TriggeredOneShot(producerFinished()),
           linkages = {
               ("", "inbox" )      : ("NET", "inbox"),
               ("NET", "outbox")   : ("SPLIT", "inbox"),
               ("SPLIT", "outbox") : ("", "outbox"),

               ("SPLIT", "outbox2") : ("STOP", "inbox"),
               ("STOP", "outbox")   : ("NET", "control"),
               ("", "control")      : ("NET", "control"),
               ("NET", "signal")    : ("SPLIT", "control"),
               ("SPLIT", "signal")  : ("", "signal"),
               ("SPLIT", "signal2"),: ("STOP", "control"),
           },
         )

OneShot Behaviour

At initialisation, specify the message to be sent by OneShot.

As soon as OneShot is activated, the specified message is sent out of the "outbox" outbox. A producerFinished message is also sent out of the "signal" outbox. The component then immediately terminates.

TriggeredOneShot Behaviour

At initialisation, specify the message to be sent by TriggeredOneShot.

Send anything to the "inbox" inbox and TriggeredOneShot will immediately send the specified message out of the "outbox" outbox. A producerFinished message is also sent out of the "signal" outbox. The component then immediately terminates.

If a producerFinished or shutdownMicroprocess message is received on the "control" inbox. It is immediately sent on out of the "signal" outbox and the component then immediately terminates.


Kamaelia.Util.OneShot.OneShot

class OneShot(Axon.Component.component)

OneShot(msg) -> new OneShot component.

Immediately sends the specified message and terminates.

Keyword arguments:

- msg  -- the message to send out

Inboxes

  • control : Shutdown signalling
  • inbox : NOT USED

Outboxes

  • outbox : Item is sent out here
  • signal : Shutdown signalling

Methods defined here

Warning!

You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.

__init__(self[, msg])

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

main(self)

Main loop

Kamaelia.Util.OneShot.TriggeredOneShot

class TriggeredOneShot(Axon.Component.component)

OneShot(msg) -> new OneShot component.

Waits for anything to arrive at its "inbox" inbox, then immediately sends the specified message and terminates.

Keyword arguments:

- msg  -- the message to send out

Inboxes

  • control : Shutdown signalling
  • inbox : Anything, as trigger

Outboxes

  • outbox : Item is sent out here
  • signal : Shutdown signalling

Methods defined here

Warning!

You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.

__init__(self[, msg])

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

main(self)

Main loop

Feedback

Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT