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)
For examples and more explanations, see the module level docs.
threadedadaptivecommscomponent([queuelengths]) -> new threadedadaptivecommscomponent
Base class for a version of an Axon adaptivecommscomponent that runs main() in a separate thread (meaning it can, for example, block).
Subclass to make your own.
Internal queues buffer data between the thread and the Axon inboxes and outboxes of the component. Set the default queue length at initialisation (default=1000).
Like an adaptivecommscomponent, inboxes and outboxes can be added and deleted at runtime.
A simple example:
class IncrementByN(Axon.ThreadedComponent.threadedcomponent):
Inboxes = { "inbox" : "Send numbers here",
"control" : "NOT USED",
}
Outboxes = { "outbox" : "Incremented numbers come out here",
"signal" : "NOT USED",
}
def __init__(self, N):
super(IncrementByN,self).__init__()
self.n = N
def main(self):
while 1:
while self.dataReady("inbox"):
value = self.recv("inbox")
value = value + self.n
self.send(value,"outbox")
if not self.anyReady():
self.pause()
Internal thread-unsafe code for adding an inbox.
Allocates a new inbox with name based on the name provided. If a box with the suggested name already exists then a variant is used instead.
Returns the name of the inbox added.
Allocates a new outbox with name based on the name provided. If a box with the suggested name already exists then a variant is used instead.
Returns the name of the outbox added.
Deletes the named inbox. Any messages in it are lost.
Try to ensure any linkages to involving this outbox have been destroyed - not just ones created by this component, but by others too! Behaviour is undefined if this is not the case, and should be avoided.
Deletes the named outbox.
Try to ensure any linkages to involving this outbox have been destroyed - not just ones created by this component, but by others too! Behaviour is undefined if this is not the case, and should be avoided.
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, 09 Dec 2009 at 04:00:25 UTC/GMT