Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

一个用redis做的分布式锁,含有超时及重试机制.

Project Description
###一个用redis实现的分布式锁,含有retry和timetout的功能。

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

更新:
1. 增加了ask_lock接口

```
#coding:utf-8
#my blog: http://xiaorui.cc
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):
time.sleep(10)
print 'welcome to my blog, http://xiaorui.cc'

```
#####同时运行test.py and test2.py
python test.py
```
root@li568-252 redis_netlock]# python test.py
welcome to my blog, http://xiaorui.cc
```

python test2.py
```
[root@li568-252 redis_netlock]# python test2.py
Sleeipng for 0.404031367603
Sleeipng for 1.19347232007
Sleeipng for 2.47668271021
Sleeipng for 4.55280708824
hello
```
Release History

Release History

This version
History Node

1.6

History Node

1.5

History Node

1.1

History Node

1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
redis_netlock-1.6.tar.gz (2.3 kB) Copy SHA256 Checksum SHA256 Source Sep 25, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting