API reference

class fluteline.Node

An abstract base class for producers, consumers, or consumer-producers in a pipeline.

Hooks
Setup resources when starting in enter and clean after yourself in exit.
Outputting values
Send messages to the next node in the pipeline with self.put(new_value).
Connect, start, and stop
First, connect the node to a destination with connect(other_node), then call start. Don’t forget to call stop. Otherwise the thread will stay alive.
connect(other_node)

Connect the output of this node to other_node’s input.

consume(msg)

Override if your node should react to incoming message, whether it’s a consumer, consumer-producer, or just a producer.

Parameters:msg – An incoming messages to process.
enter()

Override to prepare resources.

exit()

Override to cleanup after yourself.

put(msg)

Send a message to the next node in the pipeline.

stop()

Stop the node gracefully.

class fluteline.Producer

Inherit this class to create a producer.

produce()

Override to produce new messages.

class fluteline.Consumer

Inherit this class to create a consumer or consumer-producer.

Utilities

class fluteline.Logger(logger=None)

A utility consumer-producer that logs messages.

Parameters:logger – Provide your own logger or get a new fluteline logger. Logging level is logging.INFO.
fluteline.connect(nodes)

Connect a list of nodes.

fluteline.start(nodes)

Start multiple nodes.

fluteline.stop(nodes)

Stop multiple nodes.

Queues

class fluteline.Queue

Thread-safe input and output queue from nodes.

empty()

Return True if the queue is empty, False otherwise (not reliable!).

get()

Remove and return an item from the queue.

put(item)

Put an item into the queue.