Provides various kinds of Component classes.
Base class for components.
|Parameters:||kwargs (collections.Mapping) -- Any keyword arguments given at instantiation are automatically set as instance attributes for convenience.|
Sub-classes are expected to override this method. It should be a coroutine which will automatically be activated upon instantiation.
Terminate the component.
Like sample_coroutine(), any messages sent to it on any inbox will be sent back out on it's outbox outbox. It is also well behaved in that it will shutdown on any IShutdown message, forwarding it on before quitting.
The full code for this component is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
@provider(ICoroutineFactory) class SampleComponent(Component): """Component that passes all messages through.""" def _main(self): """Pass all messages through.""" inbox, message = (yield) while True: if is_shutdown(inbox, message): yield 'signal', message break ## Your code goes here. inbox, message = (yield 'outbox', message)