def process(func,msg):
def wrapper(*args,**kwargs):
if 'meta_event_type' in msg.keys() and msg['meta_event_type'] == 'lifecycle':
print("The connection is normal")
return # 退出本次处理
else:
print("A normal message")
func(*args,**kwargs)
return wrapper
@process(msg)
def test(msg):
print(msg['message'])
msg = {字典里面是一些数据}
test(msg)
我想让process装饰器先判断是否条件成立,再决定是否运行这个函数,但是process中需要msg才能正常运行,如何让process获取到msg呢