Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!


Project description


* 用with做锁的逻辑语句
* timeout避免了避免了任务出现异常,没有做delete操作
* 对于长时间的业务,增加retry重试锁的次数

1. 增加了ask_lock接口

#my blog:
from __future__ import with_statement
import redis
import time
from redis_netlock import dist_lock

client = redis.Redis(connection_pool=redis.BlockingConnectionPool(max_connections=15, host='localhost', port=6379))
with dist_lock('test', client):
print 'welcome to my blog,'

#####同时运行 and
root@li568-252 redis_netlock]# python
welcome to my blog,

[root@li568-252 redis_netlock]# python
Sleeipng for 0.404031367603
Sleeipng for 1.19347232007
Sleeipng for 2.47668271021
Sleeipng for 4.55280708824

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for redis_netlock, version 1.6
Filename, size File type Python version Upload date Hashes
Filename, size redis_netlock-1.6.tar.gz (2.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page