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!

Use memcache as a lock server

Project Description

Python module using memcache as a lock server.

Disclaimer: This code is inspired by unimr.memcachedlock . I thought I could write a simpler version of MemcachedRLock class to keep dependencies minimal (python builtins plus python-memcache), and enforcing support of gets/cas API.

WARNING: little testing has been done so far. Better review & stress this code before using it anywhere for the moment.

Example usage: import memcachelock import memcache # python-memcached doesn’t do cas correctly without cache_cas mc = memcache.Client([‘127.0.0.1:11211’], cache_cas=True) # Non-reentrant lock mclock = memcachelock.Lock(mc, ‘foo_resource’) # Per-connection reentrant lock mcrlock = memcachelock.RLock(mc, ‘foo_resource’) # Per-connection and per-thread reentrant lock rmcrlock = memcachelock.ThreadRLock(mc, ‘foo_resource’)

All lock instances have the same API as thread.LockType (as of python 2.7). ‘foo_resource’ is any string usable as a memcache key identifying some resource this lock protects. In Zope world, it might be a traversable object’s path, or a database identifier plus some database-scoped unique identifier…

Release History

Release History

This version
History Node

0.4

History Node

0.3.1

History Node

0.3

History Node

0.2

History Node

0.1

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
memcachelock-0.4.tar.gz (6.2 kB) Copy SHA256 Checksum SHA256 Source Jan 24, 2014

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