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'}) # 向订阅者发送参数