一个简单的python资源锁,确保一次只有一个进程使用特定的资源运行。
quicklock的Python项目详细描述
一个简单的python资源锁确保一次只有一个进程是 使用特定资源操作。
单重使用
singleton创建一个包含进程信息的文件,以确保 创建锁的进程仍然有效。默认位置 在当前工作目录的.lock目录中。如果这个 目录不存在,^ {TT2}$将自动创建它。
简单用法:
fromquicklockimportsingletonsingleton('my-process')# This will ensure that only one of these is running at once# The lock is released when the process that created the lock# exits (successfully or quits unexpectedly)# Intensive processing here
指定锁目录:
fromquicklockimportsingletonsingleton('my-process',dirname='/var/lock')# Now all lock files will be written to# /var/lock instead# Intensive processing here
贡献
请随意创建问题并提交请求。我想 将此库保持为有用的锁定相关的简单集合 公用事业。
许可证
许可证是mit,有关详细信息,请参阅附加的LICENSE文件 信息。