Repubsub is a publish-subscribe library built on top of RethinkDB. This is the python version of the library. There is a full article describing this library in depth.
You'll need to install RethinkDB first. You can find instructions for that on this page.
To install the library, go into the source directory containing
setup.py and run:
$ python setup.py installTo connect to an exchange, create a topic and publish to it:
import repubsub
exchange = repubsub.Exchange('exchange_name', db='database_name')
topic = exchange.topic('hi.there')
topic.publish("All subscribers to 'hi.there' will pick this up")To create a queue for listening for messages, the process is similar except you'll need to create a ReQL filter function:
queue = exchange.queue(lambda topic: topic.match('hi.*'))
for topic, message in queue.subscription():
print 'Received the message:', message
print 'on the topic:', topicIn addition, examples of usage can be found in the demo.py file. There is also an extensive description of how the library works and how to use it here.
Please report any bugs at our github issue tracker