DESCRIPTION.rst 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. [![Build Status](https://travis-ci.org/jek/blinker.svg?branch=master)](https://travis-ci.org/jek/blinker)
  2. # Blinker
  3. Blinker provides a fast dispatching system that allows any number of
  4. interested parties to subscribe to events, or "signals".
  5. Signal receivers can subscribe to specific senders or receive signals
  6. sent by any sender.
  7. >>> from blinker import signal
  8. >>> started = signal('round-started')
  9. >>> def each(round):
  10. ... print "Round %s!" % round
  11. ...
  12. >>> started.connect(each)
  13. >>> def round_two(round):
  14. ... print "This is round two."
  15. ...
  16. >>> started.connect(round_two, sender=2)
  17. >>> for round in range(1, 4):
  18. ... started.send(round)
  19. ...
  20. Round 1!
  21. Round 2!
  22. This is round two.
  23. Round 3!
  24. See the [Blinker documentation](https://pythonhosted.org/blinker/) for more information.
  25. ## Requirements
  26. Blinker requires Python 2.4 or higher, Python 3.0 or higher, or Jython 2.5 or higher.
  27. ## Changelog Summary
  28. 1.3 (July 3, 2013)
  29. - The global signal stash behind blinker.signal() is now backed by a
  30. regular name-to-Signal dictionary. Previously, weak references were
  31. held in the mapping and ephemeral usage in code like
  32. ``signal('foo').connect(...)`` could have surprising program behavior
  33. depending on import order of modules.
  34. - blinker.Namespace is now built on a regular dict. Use
  35. blinker.WeakNamespace for the older, weak-referencing behavior.
  36. - Signal.connect('text-sender') uses an alternate hashing strategy to
  37. avoid sharp edges in text identity.
  38. 1.2 (October 26, 2011)
  39. - Added Signal.receiver_connected and Signal.receiver_disconnected
  40. per-Signal signals.
  41. - Deprecated the global 'receiver_connected' signal.
  42. - Verified Python 3.2 support (no changes needed!)
  43. 1.1 (July 21, 2010)
  44. - Added ``@signal.connect_via(sender)`` decorator
  45. - Added ``signal.connected_to`` shorthand name for the
  46. ``temporarily_connected_to`` context manager.
  47. 1.0 (March 28, 2010)
  48. - Python 3.x compatibility
  49. 0.9 (February 26, 2010)
  50. - Sphinx docs, project website
  51. - Added ``with a_signal.temporarily_connected_to(receiver): ...`` support