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!

Distributed Inter-Process Communication Library implemented in Python and Memcache server

Project Description

dipc

Distributed Inter-Process Communication Library implemented in Python and Memcached. server

Using dipc

dipc library has two classes for distributed lock and semaphore, MemcacheLock and MemcacheSemaphore

Both of those clases has a first argument which is a list of memcached servers, name of lock/semaphore, ttl - timeout (in seconds). MemcacheSemaphore class has additional parameter value - which is number of processes that can access critical section.

acquire() method will wait forever until lock will be granted. You can specify argument blocking=False, and then will this methid will return True/False depending on if lock was granted or not.

>>> from dipc import MemcacheLock
... ml = MemcacheLock(["localhost:11211"], "lock", ttl=60)
... ml.acquire()
... # critical section
... ml.release()
>>> from dipc import MemcacheSemaphore
... ml = MemcacheSemaphore(["localhost:11211"], "semaphore", value=10, ttl=60)
... ml.acquire()
... # critical section
... ml.release()

There are also decorators available: distributed_lock and distributed_semaphore First argument is a list of hosts, but it also can be a function that returns list of hosts (for those environments that have config file read in a lazy manner)

>>> from dipc.decorators import distributed_lock
...
... @distributed_lock(["localhost:11211"], "lock", ttl=60)
... def foo():
...     # body
>>> from dipc.decorators import distributed_semaphore
...
... @distributed_semaphore(["localhost:11211"], "semaphore", value=10, ttl=60)
... def bar():
...     # body
Release History

Release History

This version
History Node

0.4

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
dipc-0.4.tar.gz (3.6 kB) Copy SHA256 Checksum SHA256 Source Apr 5, 2013

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