{ "info": { "author": "David Muto (pseudomuto)", "author_email": "david.muto@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Communications", "Topic :: System :: Distributed Computing", "Topic :: System :: Networking" ], "description": "kazurator\n=========\n\n|PyPI| |Build Status|\n\nA python port of the `Shared Reentrant Read Write Lock`_ recipe from `curator`_. This package dependends on `kazoo`_ for\nhandling the zookeeper bits.\n\nAt this point, you're probably wondering why I didn't just use the existing locks recipe from `kazoo`_. The original\ngoal was to make `curator`_ and `kazoo`_ respect each other's locks such that:\n\n1. Either could acquire a read lock, so long as neither held a write\n lock\n2. Either could acquire a write lock, and block either from acquiring\n either read/write locks\n\nI first attempted to patch the locks recipe in `kazoo`_, but the internals are a bit different. (**READ**: *I wasn't\nable to make it work right*).\n\nThe reason this is necessary (at least for me), is that some code was running Scala and using `curator`_, and other code\nwas running Python using `kazoo`_.\n\nInstallation\n------------\n\n::\n\n pip install kazurator==0.2.0\n\nUsage\n-----\n\nThere are two main use cases for this package. Both of them relate to\ncreating an inter-process critical region.\n\nExample of Interop with Curator\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSee the example_ directory.\n\nInter Process Mutex\n~~~~~~~~~~~~~~~~~~~\n\nTo start, let's take a look at how we could implement a simple shared\n(across process) mutex:\n\n.. code:: python\n\n from kazoo.client import KazooClient\n from kazurator import Mutex\n\n def main():\n client = KazooClient(hosts=\"YOUR_ZK_CONNECT_STRING_HERE\")\n client.start()\n\n mutex = Mutex(client, \"/some/path\")\n\n with mutex:\n # do your thread-safe thing here\n\n client.stop()\n\nThis example assumes you want a single thread to be in the critical\nregion. In order to support simultaneous multi-threaded access, you can\nset the ``max_leases`` *kwarg* to a higher number. For example:\n\n.. code:: python\n\n mutex = Mutex(client, \"/some/path\", max_leases=2) # 2 thread at a time\n\nAlso, if you'd rather not use the content management protocol, you can\ncall ``acquire`` and ``release`` directly.\n\nInter Process Read Write Lock\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn some cases, you'll need to support an unlimited number of read locks,\nbut only a single write lock. For example, suppose you were processing\nsome HDFS paths by altering the format and replacing the data (totally\nhypothetical of course :smile:).\n\nYou'd want any consumers of the data to acquire a read lock. This would\nprevent the altering process from acquiring a write lock until the\nconsumer(s) are finished. Similarly, the consumers wouldn't be able to\nacquire read locks until the altering process removes the write lock.\n\nConsumers will block until the lock is available, or timeout after the\nspecified ``timeout`` (default is ``1s``), at which point a\n``kazoo.LockTimeout`` is raised.\n\n.. code:: python\n\n from kazoo.client import KazooClient\n from kazurator import ReadWriteLock\n\n def main():\n client = KazooClient(hosts=\"YOUR_ZK_CONNECT_STRING_HERE\")\n client.start()\n\n # can optionally supply `timeout` kwarg as well\n lock = ReadWriteLock(client, \"/some/path\")\n\n with lock.write_lock: # block until write_lock is available\n # do your thread-safe thing here\n\n with lock.read_lock: # block until write_lock is gone\n # do your thread-safe thing here\n\n client.stop()\n\nDevelopment\n-----------\n\n- Clone this repo and ``pip install -r requirements.txt``\n- Run tests ``script/test nosetests``\n\nRunning the tests will spawn a docker container to run zookeeper in. It\nwill be shutdown automatically at the end of the run\n\n.. _Shared Reentrant Read Write Lock: http://curator.apache.org/curator-recipes/shared-reentrant-read-write-lock.html\n.. _curator: http://curator.apache.org/index.html\n.. _kazoo: https://kazoo.readthedocs.io/en/latest\n.. _example: https://github.com/pseudomuto/kazurator/tree/master/example/\n\n.. |PyPI| image:: https://img.shields.io/pypi/v/kazurator.svg\n :target: https://pypi.python.org/pypi/kazurator\n.. |Build Status| image:: https://travis-ci.org/pseudomuto/kazurator.svg?branch=master\n :target: https://travis-ci.org/pseudomuto/kazurator", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pseudomuto/kazurator", "keywords": "zookeeper lock", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "kazurator", "package_url": "https://pypi.org/project/kazurator/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/kazurator/", "project_urls": { "Homepage": "https://github.com/pseudomuto/kazurator" }, "release_url": "https://pypi.org/project/kazurator/0.2.0/", "requires_dist": [ "kazoo (>=2.0.0)", "kazoo (>=2.0.0); extra == 'test'", "flake8 (>=3.2.1); extra == 'test'", "nose (>=1.3.7); extra == 'test'", "pep8 (>=1.7.0); extra == 'test'", "tox (>=2.3.1); extra == 'test'" ], "requires_python": "", "summary": "Inter process lock recipes that play nice with curator", "version": "0.2.0" }, "last_serial": 2606632, "releases": { "0.1.0": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ca1e82b484444e2b62bc1009cdb43e12", "sha256": "1d78360e0d076bce38aa2c2fa70209ea636db1c48e21ca98915b936383cf6653" }, "downloads": -1, "filename": "kazurator-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ca1e82b484444e2b62bc1009cdb43e12", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14113, "upload_time": "2017-01-22T15:26:55", "url": "https://files.pythonhosted.org/packages/27/fd/101cd55b2b583da3fc79b4c674b83cd0b7766e9786090e0eb0b9bd7bbb5c/kazurator-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8d95f6780223f3bf65663e32049051aa", "sha256": "bd81b233f3d107185360c4463f055056c0a14c0bf7a296204d194afffa17e291" }, "downloads": -1, "filename": "kazurator-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8d95f6780223f3bf65663e32049051aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9387, "upload_time": "2017-01-22T15:26:57", "url": "https://files.pythonhosted.org/packages/39/a8/75e28e22e4ce252cb7b3353ccc7bd5bb891604ddab1002dc7a7cff97eb31/kazurator-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "6427d07c2eb438854880f85ed10259bb", "sha256": "2208a597e7c916c758e05f9fdc366ebf034802975547240311cae53a2d50b316" }, "downloads": -1, "filename": "kazurator-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6427d07c2eb438854880f85ed10259bb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14512, "upload_time": "2017-01-30T13:52:08", "url": "https://files.pythonhosted.org/packages/5f/41/5e16c16214ba437eb865c2f86547942a505ede1492651a730b09f54d0398/kazurator-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fe72b316e8dc143b9f67a393739bc7ea", "sha256": "21b860f067ae24bc41bf0f0026489daef1324db0b101b3e974c0cfa2d9aaf240" }, "downloads": -1, "filename": "kazurator-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fe72b316e8dc143b9f67a393739bc7ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9682, "upload_time": "2017-01-30T13:52:10", "url": "https://files.pythonhosted.org/packages/1e/ea/ff05e74d950cf168606cef092e63d8777895ed1627a4b445258c65771a39/kazurator-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6427d07c2eb438854880f85ed10259bb", "sha256": "2208a597e7c916c758e05f9fdc366ebf034802975547240311cae53a2d50b316" }, "downloads": -1, "filename": "kazurator-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6427d07c2eb438854880f85ed10259bb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14512, "upload_time": "2017-01-30T13:52:08", "url": "https://files.pythonhosted.org/packages/5f/41/5e16c16214ba437eb865c2f86547942a505ede1492651a730b09f54d0398/kazurator-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fe72b316e8dc143b9f67a393739bc7ea", "sha256": "21b860f067ae24bc41bf0f0026489daef1324db0b101b3e974c0cfa2d9aaf240" }, "downloads": -1, "filename": "kazurator-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fe72b316e8dc143b9f67a393739bc7ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9682, "upload_time": "2017-01-30T13:52:10", "url": "https://files.pythonhosted.org/packages/1e/ea/ff05e74d950cf168606cef092e63d8777895ed1627a4b445258c65771a39/kazurator-0.2.0.tar.gz" } ] }