PyPubSub is a lightweight, thread-safe publish-subscribe messaging library for Python. It provides a simple API to enable decoupled communication between different parts of an application. The current version is 4.0.7, focusing on Python 3 compatibility and performance. Releases typically happen as needed to address bug fixes, new Python version compatibility, or major feature/protocol changes.
pip install pypubsubVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to subscribe functions to a topic and publish messages. Listeners can accept positional and keyword arguments, matching the arguments passed to `sendMessage`. The `pub` object manages all subscriptions and publications.
Upgrade your Python environment to 3.7+ and then upgrade PyPubSub to v4.x. If Python 2.7 is strictly required, use `pypubsub==3.4.2`.
Remove any calls to `pub.setupArg1()`. Update listener function signatures to accept named arguments corresponding to the published message's keywords, or use `**kwargs` for flexibility.
Always install PyPubSub using `pip install pypubsub` to ensure you get the correctly packaged version from PyPI. Avoid direct installation from GitHub `.zip` or `.tar.gz` archives unless specifically instructed or for development.
For Python 3 environments, ensure you install PyPubSub v4.0.0 or later. Use `pip install 'pypubsub>=4.0.0'` or simply `pip install pypubsub` to get the latest compatible version.
First, ensure the library is installed with `pip install pypubsub`. Then, correct your import statement to `from pubsub import pub`.
Remove the call to `pub.setupArg1()`. Update your listener functions to accept named arguments directly, or use `**kwargs` if you need to capture all published arguments without specific naming.
Modify your listener function signature to include `**kwargs` if it should accept arbitrary arguments, or ensure all arguments passed via `pub.sendMessage()` are explicitly defined in the listener function signature. For example: `def listener(arg1, arg2, extra_key=None):` or `def listener(arg1, arg2, **kwargs):`
No dependency data recorded yet.