快速、简单的对象到对象和广播信号
blinker的Python项目详细描述
Blinker提供一个快速调度系统,允许任意数量的 相关方订阅事件或“信号”
信号接收器可以订阅特定的发送者或接收信号 由任何发件人发送
>>> from blinker import signal >>> started = signal('round-started') >>> def each(round): ... print "Round %s!" % round ... >>> started.connect(each)>>> def round_two(round): ... print "This is round two." ... >>> started.connect(round_two, sender=2)>>> for round in range(1, 4): ... started.send(round) ... Round 1! Round 2! This is round two. Round 3!
有关详细信息,请参见Blinker documentation。
要求
Blinker需要Python2.4或更高版本、Python3.0或更高版本、Jython2.5或更高版本。
变更日志摘要
1.4(2015年7月23日)
- Verified Python 3.4 support (no changes needed)
- Additional bookkeeping cleanup for non-ANY connections at disconnect time.
- Added Signal._cleanup_bookeeping() to prune stale bookkeeping on demand
1.3(2013年7月3日)
- The global signal stash behind blinker.signal() is now backed by a regular name-to-Signal dictionary. Previously, weak references were held in the mapping and ephemeral usage in code like ^{tt1}$ could have surprising program behavior depending on import order of modules.
- blinker.Namespace is now built on a regular dict. Use blinker.WeakNamespace for the older, weak-referencing behavior.
- Signal.connect(‘text-sender’) uses an alternate hashing strategy to avoid sharp edges in text identity.
1.2(2011年10月26日)
- Added Signal.receiver_connected and Signal.receiver_disconnected per-Signal signals.
- Deprecated the global ‘receiver_connected’ signal.
- Verified Python 3.2 support (no changes needed!)
1.1(2010年7月21日)
- Added ^{tt2}$ decorator
- Added ^{tt3}$ shorthand name for the ^{tt4}$ context manager.
1.0(2010年3月28日)
- Python 3.x compatibility
0.9(2010年2月26日)
- Sphinx docs, project website
- Added ^{tt5}$ support