import fcntl
pid_file ='program.pid'fp = open(pid_file,'w')
try:
fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
exceptIOError:
# another instance is running
sys.exit(0)
另外fcntl.flock是直接對整個文件進行加鎖,而fcntl.lockf是可以指定對文件中的某一段加鎖(參數可以指定起止位置)
import fcntl
pid_file ='program.pid'另外fcntl.flock是直接對整個文件進行加鎖,而fcntl.lockf是可以指定對文件中的某一段加鎖(參數可以指定起止位置)
繼續運行 🥋 回憶上次內容 上上次 真寫了 萬行 代碼 這 萬行 代碼 都是寫在 明面 上的 這次 使用git命令 下載了 github上面的倉庫