Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
/ pypubsub Public archive

PyPubSub: basic inter-process communication implementation with publish-subscribe messaging pattern

Notifications You must be signed in to change notification settings

SamyAB/pypubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyPubSub: Simple Inter-Process Communication

A light-weight implementation of an application that handles multiple processes inter-communication using the publish-subscribe messaging pattern in Python.

Demonstration

Run the demonstration

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.

Understand the demonstration

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.

Development

Environment and Requirements

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\]

Adapt the PyPubSub to you use case

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.

Possible Improvements

  • Handle signals SIGTERM and SIGKILL
  • Have the topics' reader connections close when their writer counterparts are closed
  • Add integration and end-to-end tests

About

PyPubSub: basic inter-process communication implementation with publish-subscribe messaging pattern

Resources

Stars

Watchers

Forks

Packages

No packages published