Recommended Python publish/subscribe/dispatch module?

Here is a newer one: https://github.com/shaunduncan/smokesignal. "smokesignal is a simple python library for sending and receiving signals. It draws some inspiration from the django signal framework but is meant as a general purpose variant." Example:

from time import sleep
import smokesignal

@smokesignal.on('debug')
def verbose(val):
    print "#", val


def main():
    for i in range(100):
        if i and i%10==0:
            smokesignal.emit('debug', i)
        sleep(.1)

main()

The best dispatch package for python seems to be the dispatch module inside django (called signals in the documentation). It is independent of the rest of django, and is short, documented, tested and very well written.

Edit: I forked this project into an independent signal project for Python.


PyDispatcher is used heavily in Django and it's working perfectly for me (and for whole Django community, I guess).

As I remember, there are some performance issues:

  • Arguments checking made by PyDispatcher is slow.
  • Unused connections have unnecessary overhead.

AFAIK it's very unlikely you will run into this issues in a small-to-medium sized application. So these issues may not concern you. If you think you need every pound of performance (premature optimization is the root of all evil!), you can look at modifications done to PyDispatcher in Django.

Hope this helps.