Sherlock 介绍
Sherlock 是一个易用的 Python 分布式进程内锁机制库,你可选择锁同步的不同后台。
示例代码:
import sherlock from sherlock import Lock # Configure Sherlock's locks to use Redis as the backend, # never expire locks and retry acquiring an acquired lock after an # interval of 0.1 second. sherlock.configure(backend=sherlock.backends.REdis, expire=None, retry_interval=0.1) # Note: configuring sherlock to use a backend does not limit you # another backend at the same time. You can import backend specific locks # like RedisLock, MCLock and EtcdLock and use them just the same way you # use a generic lock (see below). In fact, the generic Lock provided by # sherlock is just a proxy that uses these specific locks under the hood. # acquire a lock called my_lock lock = Lock('my_lock') # acquire a blocking lock lock.acquire() # check if the lock has been acquired or not lock.locked() == True # release the lock lock.release()
Sherlock 官网
https://github.com/vaidik/sherlock
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。