def goumai(i): with dist_lock('test',r): num=post.find_one({"_id":2}) m=num.get('num') print m post.update({"_id":2},{"$set":{"num":m+i}})
#coding:utf-8 import redis import time from redis_netlock import dist_lock, ask_lock client = redis.Redis(connection_pool=redis.BlockingConnectionPool( max_connections=15, host='localhost', port=6379)) with dist_lock('test', client) as l: time.sleep(10) print 'welcome to 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): print 'hello'
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"