Message service implementing publisher/subscriber pattern
Project description
apubsub
Simple, single-purpose message service implementation.
Note that service is started in stand-alone process, so start it as early as possible to minimize resource pickling
Installation
Python versin 3.7+ required
Just install it with pip: pip install apubsub
Usage
The most simple usage is to subscribe to topic and receive single message:
from apubsub import Service
service = Service()
service.start()
pub = service.get_client()
sub = service.get_client() # every client can perform both pub and sub roles
sub.subscribe('topic')
pub.publish('topic', 'some data') # publish put data to subscribed Client queue
pub.publish('topic', 'some more data')
pub.publish('topic', 'and more')
data = sub.get_single(timeout=0.1) # 'some data'
data = sub.get_all() # ['some more data', 'and more']
Also, Client
provides start_receiving
async generator for receiving messages on-demand.
It will wait for new messages until interrupted by stop_receiving
call
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apubsub-0.1.0.tar.gz
(6.5 kB
view hashes)