#yyds干货盘点# python-redis-lock锁

仓廪实则知礼节,衣食足则知荣辱。这篇文章主要讲述#yyds干货盘点# python-redis-lock锁相关的知识,希望能为你提供帮助。
项目地址
【#yyds干货盘点# python-redis-lock锁】??https://pypi.org/project/python-redis-lock/??
安装

pip install python-redis-lock

很全的锁,能自动续约续租,强烈建议使用
from redis import Redis
conn = Redis()

import redis_lock
lock = redis_lock.Lock(conn, "name-of-the-lock")
if lock.acquire(blocking=False):
print("Got the lock.")
lock.release()
else:
print("Someone else has the lock.")






    推荐阅读