rdlm-py is a python client for RDLM (Restful Distributed Lock Manager)
Project description
What is it ?
rdlm-py is a python client for the restful-distributed-lock-manager (RDLM).
Special features
Classic and administrative (password protected) requests
Two ways to use it (a classical API and a (more pythonic) ContextManager API)
Quickstart
Installation
pip install rdlm-py Requirements: - Python 2.6, 2.7, 3.2 or 3.3 - Requests >= 1.0.4
Classic API
# Import the Classic client class from rdlmpy import RDLMClient from rdlmpy import RDLMException # Make a client object with some default parameters client = RDLMClient(server="localhost", port=8888, default_title="classic example", default_lifetime=300, default_wait=10) # Acquire a lock on resource : foo lock_url = client.lock_acquire("foo") # We have the lock on resource : foo # [...] # Try to acquire the same lock another time with a overrided wait timeout of 3 seconds # => RDLMException try: lock_url2 = client.lock_acquire("foo", wait=3) except RDLMException: print "Can't acquire the lock" # Release the lock result = client.lock_release(lock_url) if not(result): print "Can't release the lock"
Context Manager API
# Import the Context Manager class class from rdlmpy import RDLMContextManager with RDLMContextManager("foo") as c: # We have the lock on resource: foo # [...] # No need to release the lock, even if an exception is raised # Here, we don't have the lock anymore # [...]
Warning
rdlm-py is at an early stage of development (API can change).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rdlm-py-0.1.a5.tar.gz
(12.9 kB
view hashes)