学习blinker

from blinker import signal

do_sth = signal('do_sth')  #创建信号

def process(f, a, b, **kwargs):
    f(a, b, **kwargs)
    print('Has done!')


def f(a, b, **kwargs):
    print(f'loc: {a}, {b}; kwargs:{kwargs}')
    print('do something.')

do_sth.connect(process) # process订阅信号
do_sth.send(f, **{'hello': 'world', 'a': 'a', 'b': 'b'})  # 向订阅者发送参数
posted @ 2018-12-26 21:02  成民  阅读(325)  评论(0编辑  收藏  举报