A light-weight implementation of an application that handles multiple processes inter-communication using the publish-subscribe messaging pattern in Python.
To showcase the implementation of the pattern, the application can be run in demonstration mode using the command:
docker-compose up
For this command to work, ensure your current working directory is located at the project root, and that you have Docker and Docker Compose installed.
The demonstration creates a publisher named MotionDetector that sends MotionVectors in the topic motion_vector.
A publisher/subscriber named SingleShotDetector subscribes to the topic motion_vector and transforms its content, in order to publish the result as a DetectionVector in the topic named detection_vector.
Lastly, a subscriber named Logger subscribes to both topics, and prints the messages in them on the standard output.
The proposed implementation uses only python built-in packages, making it as lightweight as possible.
That being said, if you want to contribute or use this package you may want to install dev requirements.
pip install .[dev]
Note: In case the command returns the error
no matches found: .[dev]
You should try ot escape the brackets
pip install .\[dev\]
You may extend the base_publisher_subscriber subpackage to create publishers and subscribers, following the examples in the motion_detection subpackage.
To better understand the global usage of the topics' mechanics, please refer to the main module of the package.
Finally, note that publishers can only publish in a single topic, while subscribers can subscribe to multiple topics at once.
- Handle signals SIGTERM and SIGKILL
- Have the topics' reader connections close when their writer counterparts are closed
- Add integration and end-to-end tests