This is the main entry-point to pubsub’s core functionality. The pub
module supports:
The recommended usage is
from pubsub import pub
// use pub functions:
pub.sendMessage(...)
Note that this module creates a “default” instance of pubsub.core.Publisher and binds several local functions to some of its methods and those of the pubsub.core.TopicManager instance that it contains. However, an application may create as many independent instances of Publisher as required (for instance, one in each thread; with a custom queue to mediate message transfer between threads).
getDefaultPublisher |
Get the Publisher instance created by default when this module |
getDefaultTopicMgr |
Get the TopicManager instance created by default when this |
instantiateAllDefinedTopics |
Loop over all topics of given provider and “instantiate” each topic, thus |
isSubscribed |
Returns true if listener has subscribed to topicName, false otherwise. |
isValid |
Return true only if listener can subscribe to messages of given topic. |
validate |
Checks if listener can subscribe to topicName. If not, raises |
getDefaultPublisher
()¶Get the Publisher instance created by default when this module is imported. See the module doc for details about this instance.
getDefaultTopicMgr
()¶Get the TopicManager instance created by default when this
module is imported. This function is a shortcut for
pub.getDefaultPublisher().getTopicMgr()
.
instantiateAllDefinedTopics
(provider)¶Loop over all topics of given provider and “instantiate” each topic, thus forcing a parse of the topics documentation, message data specification (MDS), comparison with parent MDS, and MDS documentation. Without this function call, an error among any of those characteristics will manifest only if the a listener is registered on it.
isSubscribed
(listener, topicName)¶Returns true if listener has subscribed to topicName, false otherwise. WARNING: a false return is not a guarantee that listener won’t get messages of topicName: it could receive messages of a subtopic of topicName.
isValid
(listener, topicName)¶Return true only if listener can subscribe to messages of given topic.
validate
(listener, topicName)¶Checks if listener can subscribe to topicName. If not, raises ListenerMismatchError, otherwise just returns.