''' 线程锁 ''' import threading import time lock = threading.Lock() lock.acquire() #获取锁 lock.release() #释放锁 #with lock: #自动开启,关闭锁 with lock: time.sleep(3) #相似 # with open("1.txt","w") as f: # f.close() #kafka go开发