August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
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.
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"),
},
)
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.
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.
OneShot(msg) -> new OneShot component.
Immediately sends the specified message and terminates.
Keyword arguments:
- msg -- the message to send out
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.
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Main loop
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
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.
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Main loop
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