python 锁 装饰器

锁 装饰器

from threading import Lock

signal_lock = Lock()

def send_signal_lock(func):
    def inner(*args,**kwargs):
        signal_lock.acquire()
        res = func(*args,**kwargs)
        signal_lock.release()
        return res
    return inner
posted @ 2021-08-27 10:50  pythoner_wl  阅读(233)  评论(0编辑  收藏  举报