Pub Module

Sending Messages

Sending messages is achieved via the following function:

The following exception may be raised when sending a message, if the message data does not comply with the Message Data Specification for the topic:

Advanced use:

The following would typically only be useful in special circumstances, such as if pubsub’s default Publisher must be accessed, on or more separate instances of Publisher is required, and so forth.

Receiving Messages

The following functions are available for controlling what callable objects (functions, methods, or class instances with a __call__ method) will get called when messages are generated:

The following exceptions are relevant:

AUTO_TOPIC

Use this as default parameter in a listener’s signature: the listener will be given the Topic object of the message.

The following additional functions may be useful during debugging:

Advanced use:

The following are not typically required but can be useful in certain circumstances, especially during debugging:

Topics

In most cases, topics are used by name in dotted string format. The following may be useful for basic pubsub use:

Advanced use:

Some advanced uses of pubsub, especially (but not only) for debugging a pubsub-based application, could require access to the associated Topic instance, topic tree manager, special topic-related constants, or other helper functions and classes.

ALL_TOPICS

Name of topic that is root of topic tree. Subscribe a listener to this topic to get all pubsub messages. Use **kwargs to receive all message data, regardless of topic.

topicTreeRoot

The topic object that is parent of all root topics. The name of this topic is pub.ALL_TOPICS.

topicsMap

The dictionary that maps topic names to Topic objects.

Advanced use:

The following are not typically required but can be useful in certain circumstances, such as during debugging:

Listener Exception Handling

Listeners that leak exceptions are typically burried deep into the stacktrace, and can cause an application to abort. The following may simplify the task of providing useful error messages from misbehaved listeners, without interrupting the application or even the pubsub send-message:

See pubsub.utils.exchandling for ready-made exception handlers which may fit your requirements.

Pubsub Tracing (aka Notification)

While debugging an application it may be useful to trap some of pubsub’s activity:

See pubsub.utils for some ready-made notification handlers which may fit your requirements.

Topic Specification

Topic definition, documentation, and MDS:

Developer:

The following are useful to extend the capabilities of pubsub to support more topic definition providers or serialization formats for the builtin provider: