{ "info": { "author": "Vaidik Kapoor", "author_email": "kapoor.vaidik@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "\nSherlock: Distributed Locks with a choice of backend\n====================================================\n\nSherlock is a library that provides easy-to-use distributed inter-process\nlocks and also allows you to choose a backend of your choice for lock\nsynchronization.\n\n|Build Status| |Coverage Status|\n\n.. |Build Status| image:: https://travis-ci.org/vaidik/sherlock.png\n :target: https://travis-ci.org/vaidik/sherlock/\n.. |Coverage Status| image:: https://coveralls.io/repos/vaidik/incoming/badge.png\n :target: https://coveralls.io/r/vaidik/incoming\n\nOverview\n--------\n\nWhen you are working with resources which are accessed by multiple services or\ndistributed services, more than often you need some kind of locking mechanism\nto make it possible to access some resources at a time.\n\nDistributed Locks or Mutexes can help you with this. Sherlock provides\nthe exact same facility, with some extra goodies. It provides an easy-to-use API\nthat resembles standard library's `threading.Lock` semantics.\n\nApart from this, Sherlock gives you the flexibility of using a backend of\nyour choice for managing locks.\n\nSherlock also makes it simple for you to extend Sherlock to use\nbackends that are not supported.\n\nFeatures\n++++++++\n\n* API similar to standard library's `threading.Lock`. \n* Support for With statement, to cleanly acquire and release locks.\n* Backend agnostic: supports `Redis`_, `Memcached`_ and `Etcd`_ as choice of\n backends.\n* Extendable: can be easily extended to work with any other of backend of\n choice by extending base lock class. Read ``extending``.\n\n.. _Redis: http://redis.io\n.. _Memcached: http://memcached.org\n.. _Etcd: http://github.com/coreos/etcd\n\nSupported Backends and Client Libraries\n+++++++++++++++++++++++++++++++++++++++\n\nFollowing client libraries are supported for every supported backend:\n\n* Redis: `redis-py`_\n* Memcached: `pylibmc`_\n* Etcd: `python-etcd`_\n\n.. _redis-py: http://github.com\n.. _pylibmc: http://github.com\n.. _python-etcd: https://github.com/jplana/python-etcd\n\nAs of now, only the above mentioned libraries are supported. Although\nSherlock takes custom client objects so that you can easily provide\nsettings that you want to use for that backend store, but Sherlock also\nchecks if the provided client object is an instance of the supported clients\nand accepts client objects which pass this check, even if the APIs are the\nsame. Sherlock might get rid of this issue later, if need be and if\nthere is a demand for that.\n\nInstallation\n------------\n\nInstallation is simple.\n\n.. code:: bash\n\n pip install sherlock\n\n.. note:: Sherlock will install all the client libraries for all the\n supported backends.\n\nBasic Usage\n-----------\n\nSherlock is simple to use as at the API and semantics level, it tries to\nconform to standard library's ``threading.Lock`` APIs.\n\n.. code-block:: python\n\n import sherlock\n from sherlock import Lock\n\n # Configure Sherlock's locks to use Redis as the backend,\n # never expire locks and retry acquiring an acquired lock after an\n # interval of 0.1 second.\n sherlock.configure(backend=sherlock.backends.REDIS,\n expire=None,\n retry_interval=0.1)\n\n # Note: configuring sherlock to use a backend does not limit you\n # another backend at the same time. You can import backend specific locks\n # like RedisLock, MCLock and EtcdLock and use them just the same way you\n # use a generic lock (see below). In fact, the generic Lock provided by\n # sherlock is just a proxy that uses these specific locks under the hood.\n\n # acquire a lock called my_lock\n lock = Lock('my_lock')\n\n # acquire a blocking lock\n lock.acquire()\n\n # check if the lock has been acquired or not\n lock.locked() == True\n\n # release the lock\n lock.release()\n\nSupport for ``with`` statement\n++++++++++++++++++++++++++++++\n\n.. code-block:: python\n\n # using with statement\n with Lock('my_lock'):\n # do something constructive with your locked resource here\n pass\n\nBlocking and Non-blocking API\n+++++++++++++++++++++++++++++\n\n.. code-block:: python\n\n # acquire non-blocking lock\n lock1 = Lock('my_lock')\n lock2 = Lock('my_lock')\n \n # successfully acquire lock1\n lock1.acquire()\n\n # try to acquire lock in a non-blocking way\n lock2.acquire(False) == True # returns False\n\n # try to acquire lock in a blocking way\n lock2.acquire() # blocks until lock is acquired to timeout happens\n\nUsing two backends at the same time\n+++++++++++++++++++++++++++++++++++\n\nConfiguring Sherlock to use a backend does not limit you from using\nanother backend at the same time. You can import backend specific locks like\nRedisLock, MCLock and EtcdLock and use them just the same way you use a generic\nlock (see below). In fact, the generic Lock provided by Sherlock is just\na proxy that uses these specific locks under the hood.\n\n.. code-block:: python\n\n import sherlock\n from sherlock import Lock\n\n # Configure Sherlock's locks to use Redis as the backend\n sherlock.configure(backend=sherlock.backends.REDIS)\n\n # Acquire a lock called my_lock, this lock uses Redis\n lock = Lock('my_lock')\n\n # Now acquire locks in Memcached\n from sherlock import MCLock\n mclock = MCLock('my_mc_lock')\n mclock.acquire()\n\nTests\n-----\n\nTo run all the tests (including integration), you have to make sure that all\nthe databases are running. Make sure all the services are running:\n\n.. code:: bash\n\n # memcached\n memcached\n\n # redis-server\n redis-server\n\n # etcd (etcd is probably not available as package, here is the simplest way\n # to run it).\n wget https://github.com/coreos/etcd/releases/download//etcd--.tar.gz\n tar -zxvf etcd--.gz\n ./etcd--/etcd\n\nRun tests like so:\n\n.. code:: bash\n\n python setup.py test\n\nDocumentation\n-------------\n\nAvailable `here`_.\n\n.. _here: http://sher-lock.readthedocs.org\n\nRoadmap\n-------\n\n* Support for `Zookeeper`_ as backend.\n* Support for `Gevent`_, `Multithreading`_ and `Multiprocessing`_.\n\n.. _Zookeeper: http://zookeeper.apache.org/\n.. _Gevent: http://www.gevent.org/\n.. _Multithreading: http://docs.python.org/2/library/multithreading.html\n.. _Multiprocessing: http://docs.python.org/2/library/multiprocessing.html\n\nLicense\n-------\n\nSee `LICENSE`_.\n\n**In short**: This is an open-source project and exists for anyone to use it\nand/or modify it for personal use. Just be nice and attribute the credits\nwherever you can. :)\n\n.. _LICENSE: http://github.com/vaidik/sherlock/blob/master/LICENSE.rst\n\nQuestions?\n----------\n\nYou are encouraged to ask questions using `issues`_ as that helps everyone and\nmyself when people with better know-how contribute to the discussion. However,\nif you wish to get in touch with me personally, then I can be contacted at\n**kapoor.vaidik++github+sherlock@gmail.com**.\n\n.. _issues: https://github.com/vaidik/sherlock/issues\n\nDistributed Locking in Other Languages\n--------------------------------------\n\n* NodeJS - https://github.com/thedeveloper/warlock\n\n\n\nCHANGELOG\n---------\n\nDevelopment Version\n+++++++++++++++++++\n\n0.3.2\n*****\n\n* [BUGFIX] `redis>=2.10.6` client won't work with `sherlock 0.3.1` #32_\n\n.. _#32: https://github.com/vaidik/sherlock/issues/32\n\n0.3.1\n*****\n\n* [BUGFIX] Python 3 support for `sherlock`\n\n0.3.0\n*****\n\n* [BUGFIX] `sherlock.Lock` should use globally configured client object.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "sherlock", "package_url": "https://pypi.org/project/sherlock/", "platform": "Any", "project_url": "https://pypi.org/project/sherlock/", "project_urls": null, "release_url": "https://pypi.org/project/sherlock/0.3.2/", "requires_dist": null, "requires_python": "", "summary": "Distributed inter-process locks with a choice of backend.", "version": "0.3.2" }, "last_serial": 5255820, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "08fa0e97e7078ee7938e58282b8a14c6", "sha256": "231abedd5c979740bd0c52bb160b9135d7d4cbcc7f86ba1472bc66018a5c738e" }, "downloads": -1, "filename": "sherlock-0.1.0.tar.gz", "has_sig": true, "md5_digest": "08fa0e97e7078ee7938e58282b8a14c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12870, "upload_time": "2014-01-31T22:17:42", "url": "https://files.pythonhosted.org/packages/9b/7b/0c16a665b1c1c50bf4f2f69599df449931bdcdef74600a950c073ed99bad/sherlock-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "ce44e43e2b2a85ce00493c83889a47b2", "sha256": "630157798a737e57aff466f7c41cf4825daafcad137298507d7291f46cd1256a" }, "downloads": -1, "filename": "sherlock-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ce44e43e2b2a85ce00493c83889a47b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13633, "upload_time": "2014-01-31T22:28:09", "url": "https://files.pythonhosted.org/packages/8f/6d/12a8362c1401442fa8fe0658ce1dfc196eb97d0d9d1adcb5b0c794fe4bb4/sherlock-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "f80c79369503ef8fe0a4fee63c0e0c62", "sha256": "c6d84652ee51a3386479d6ddfdb541022852ae62f590931ef3f7f9e614642506" }, "downloads": -1, "filename": "sherlock-0.3.0.tar.gz", "has_sig": false, "md5_digest": "f80c79369503ef8fe0a4fee63c0e0c62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13819, "upload_time": "2014-04-03T10:06:21", "url": "https://files.pythonhosted.org/packages/70/6c/359537b57cc5ab54b61760248ab303212647b143de24430cc5bbe1f8e8cb/sherlock-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "bb2484b82a76883da1a33b95e83ca698", "sha256": "91f35d207d5a2d044b5bd8c65cdd5002be619815bd283548bfe94eaf3dc4d6b5" }, "downloads": -1, "filename": "sherlock-0.3.1.tar.gz", "has_sig": false, "md5_digest": "bb2484b82a76883da1a33b95e83ca698", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12271, "upload_time": "2018-04-21T20:38:20", "url": "https://files.pythonhosted.org/packages/01/74/e3def1f3b66b1017e5a2a4f956c2e3ac67471b53e6d102f2c10c4e732cab/sherlock-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "a8ef487821428335ae7cabdfdb9e2589", "sha256": "6f32119e211ea3b3c76d3842d0b44cde1118eb1c3fb3b24265f84eafad6ee37a" }, "downloads": -1, "filename": "sherlock-0.3.2.tar.gz", "has_sig": false, "md5_digest": "a8ef487821428335ae7cabdfdb9e2589", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14797, "upload_time": "2019-05-11T11:26:59", "url": "https://files.pythonhosted.org/packages/84/2f/f7ee535b754d661b965b8c7efe3f897d01da5afa6d13cf9d66a17436997a/sherlock-0.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a8ef487821428335ae7cabdfdb9e2589", "sha256": "6f32119e211ea3b3c76d3842d0b44cde1118eb1c3fb3b24265f84eafad6ee37a" }, "downloads": -1, "filename": "sherlock-0.3.2.tar.gz", "has_sig": false, "md5_digest": "a8ef487821428335ae7cabdfdb9e2589", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14797, "upload_time": "2019-05-11T11:26:59", "url": "https://files.pythonhosted.org/packages/84/2f/f7ee535b754d661b965b8c7efe3f897d01da5afa6d13cf9d66a17436997a/sherlock-0.3.2.tar.gz" } ] }