Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nokia/moler/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Moler is IO-agnostic. The same observer code runs on top of TCP, SSH, serial, in-memory, or any other transport.ConnectionFactory manages the registry of available transports and creates connection instances on demand.
There are two entry points:
get_connection()— module-level convenience function. Handles named connections from configuration and variant resolution.ConnectionFactory— the underlying class-based registry. Use directly to register custom transports or query available variants.
Module-level function
get_connection
name or io_type, not both.
Name of a connection defined in Moler’s configuration. The factory looks up the
io_type and constructor arguments from the configuration, then constructs the connection. The name value is also passed to the connection constructor (if it accepts it) so the connection’s logger is named accordingly.Transport type. Built-in values include
'tcp', 'udp', 'ssh', 'terminal', 'sshshell', 'memory'. Custom types can be registered via ConnectionFactory.register_construction().Implementation variant such as
'threaded', 'asyncio', or 'twisted'. If None, the variant is resolved from the configuration’s default_variant mapping for the given io_type.Additional keyword arguments forwarded directly to the connection constructor. For example,
host and port for TCP connections.AssertionError— if neithernamenorio_typeis provided, or if both are provided.KeyError— if the named connection is not in the configuration, or ifvariantis not registered.AttributeError— ifio_type='terminal'is requested on Windows.
ConnectionFactory class
ConnectionFactory implements the registry. All methods are class methods.
register_construction
io_type/variant pair. Call this once at import time when providing a custom transport.
Transport type identifier, e.g.
'tcp', 'myserial'.Implementation variant identifier, e.g.
'threaded', 'asyncio'.Any callable — typically a class or a factory function — that accepts
**constructor_kwargs and returns a connection instance. Must be callable; raises ValueError otherwise.get_connection
(io_type, variant). This is the low-level method; prefer the module-level get_connection() for normal use.
Transport type.
Implementation variant.
Arguments forwarded to the registered constructor.
KeyError if no constructor is registered for the (io_type, variant) pair.
available_variants
io_type.
Transport type to query.
['threaded', 'asyncio']. Returns an empty list if io_type has no registrations.
Usage examples
Since Moler 2.0.0 the default registered connection type uses
MolerConnectionForSingleThreadRunner. If you rely on the older ThreadedMolerConnection behaviour, register it explicitly before creating connections.