{ "info": { "author": "Adrian Vandier Ast", "author_email": "adrian.vandierast@sewan.fr", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6" ], "description": "mutextree\n==========\n|black|\n\nTo protect tree-like resources:\n\n.. image:: https://raw.githubusercontent.com/SewanDevs/mutextree/master-github/images/mutextree-voc.png\n\nNodes have to be represented by their fully qualified name.\nFor instance, the node D is represented by [A, B, D]:\n\n.. image :: https://raw.githubusercontent.com/SewanDevs/mutextree/master-github/images/mutextree-qualified-name.png\n\nThe algorithm to lock a node is the following:\n\n1. We lock the parent nodes in order:\n\n.. image :: https://raw.githubusercontent.com/SewanDevs/mutextree/master-github/images/mutextree-step1.png\n\n.. image :: https://raw.githubusercontent.com/SewanDevs/mutextree/master-github/images/mutextree-step2.png\n\n2. Then we check that no child node is already locked:\n\n.. image :: https://raw.githubusercontent.com/SewanDevs/mutextree/master-github/images/mutextree-step3.png\n\n3. We lock the wanted node\n\n.. image :: https://raw.githubusercontent.com/SewanDevs/mutextree/master-github/images/mutextree-step4.png\n\n4. We release all the parent locks that are no longer usefull.\n\n.. image :: https://raw.githubusercontent.com/SewanDevs/mutextree/master-github/images/mutextree-step5.png\n\n\nInterface targeted to be exactly like threading.Lock_.\n\n.. _threading.Lock : `\n\nThe mutex tree is actually designed to use redis and python-redis-lock but the locking backend may be changed.\n\n\nUsage\n------------\n\nTo use mutextree with the redis locks back end, simply instanciate a redis client and create your lock.\nThe redis client should be strict and decode responses itself.\n\n.. code-block:: python\n\n import redis\n from mutextree import RedisLockBackend, TreeLock\n\n redis_client = redis.StrictRedis(decode_responses=True)\n redis_lock_backend = RedisLockBackend(redis_client)\n lock = TreeLock(redis_lock_backend, [\"nodeA\"], expire=10, timeout=10, id=1)\n try:\n lock.acquire()\n # do things\n finally:\n lock.release()\n\n\nYou can use it as a context manager or a decorator:\n\n.. code-block:: python\n\n import redis\n from mutextree import RedisLockBackend, TreeLock, tree_lock\n\n redis_client = redis.StrictRedis(decode_responses=True)\n redis_lock_backend = RedisLockBackend(redis_client)\n\n with TreeLock(redis_lock_backend, [\"nodeA\"], expire=10):\n # do things\n pass\n # release will be automatically called\n\n # Or with a decorator\n @tree_lock(redis_lock_backend, [\"nodeA\"], expire=10)\n def protected_function():\n # do things\n pass\n # release will be automatically called\n\n\nLock has the same basic interface as threading.Lock() with some more methods: acquire, release, refresh.\n\n\nTests\n------\n\nTests should be run under python 2.7 and python 3.6 to tests everything\n\n.. code-block:: console\n\n $ pip install tox\n $ tox -e py27,py36\n\nCoverage reports will be the merge of the coverage for py27 and py36.\n\n.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/ambv/black", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SewanDevs/mutextree", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "mutextree", "package_url": "https://pypi.org/project/mutextree/", "platform": "", "project_url": "https://pypi.org/project/mutextree/", "project_urls": { "Homepage": "https://github.com/SewanDevs/mutextree" }, "release_url": "https://pypi.org/project/mutextree/1.2.3/", "requires_dist": null, "requires_python": "", "summary": "Protect tree-like resources", "version": "1.2.3" }, "last_serial": 5267822, "releases": { "1.2.3": [ { "comment_text": "", "digests": { "md5": "df20fed12350c60dfeb2fe88a6d42db6", "sha256": "e0e4d32a85af51dd3db7bc94f26febd75bbac803a1509f53a3614c0fa483892c" }, "downloads": -1, "filename": "mutextree-1.2.3.tar.gz", "has_sig": false, "md5_digest": "df20fed12350c60dfeb2fe88a6d42db6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 189493, "upload_time": "2019-05-14T14:46:17", "url": "https://files.pythonhosted.org/packages/cd/9c/675bf05e768d60f3e1006f3d476d6db452c714e24d85160c47e934240f49/mutextree-1.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "df20fed12350c60dfeb2fe88a6d42db6", "sha256": "e0e4d32a85af51dd3db7bc94f26febd75bbac803a1509f53a3614c0fa483892c" }, "downloads": -1, "filename": "mutextree-1.2.3.tar.gz", "has_sig": false, "md5_digest": "df20fed12350c60dfeb2fe88a6d42db6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 189493, "upload_time": "2019-05-14T14:46:17", "url": "https://files.pythonhosted.org/packages/cd/9c/675bf05e768d60f3e1006f3d476d6db452c714e24d85160c47e934240f49/mutextree-1.2.3.tar.gz" } ] }