Using batons

A baton is any Python object that is processed in a pipeline.

What happens to a baton during processing is entirely up to the processors: a processor may replace the baton with a new one, or add, update or remove keys in a mutable baton.

Baton types

There are two kinds of batons: mutable and immutable batons, which is described in the following sections.

Mutable batons

A mutable baton is any Python object that is mutable – for example dicts instances are the most commonly used batons.

When using mutable batons in a processor graph containing multiple sources or trees, keep in mind that all the consumers receives the same baton, and thus will see each others changes. If this is undesirable, a processor such as copy may be used.

Immutable batons

Python objects that are immutable, such as strs may be used by some providers such as the zmq provider.

Processor interdependencies

Processors in a pipeline receive the output baton of the previous processor as its input.

Since any processor may change the baton in any way it sees fit, this creates an interdependency between batons in a pipeline, as processors later in a processor graph often depend on a baton conforming to a certain format or that certain values have been set in a dict-like baton.

Table Of Contents

Previous topic

Working with pipelines

Next topic

Using dependencies

This Page