{ "info": { "author": "Pawel", "author_email": "inne.poczta@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries" ], "description": "**PyYADL** (Yet Another Distributed Lock)\n=========================================\n\ndescription\n-----------\n\nThis is yet another distributed lock for Python with interface\ncompatible with standard Lock/RLock class (only constructor parameters\nare different and release method has one optional parameter *force*)\n\nCurrently there is only one implementation, based on Redis, but it's\nvery easy to extend base class and adapt it to any other distributed\nstorage (like Etcd, databases - both relational and NoSQL, distributed\nfile systems etc.)\n\nRedis lock\n----------\n\nusage\n~~~~~\n\nexamples:\n^^^^^^^^^\n\n**Create lock object**\n\n.. code:: python\n\n from PyYADL import RedisLock\n lock = RedisLock(name='test_lock', prefix='my_app', ttl=60, existing_connection_pool=None, redis_host='127.0.0.1', redis_port=6379, redis_password='secret', redis_db=0)\n\nParameters meaning: \\* **name** - each resource should have unique lock\nname, which would be shared across all systems. ``Required`` \\*\n**prefix** - prefix useful to avoid conflicts in names. ``Optional`` \\*\n**ttl** - how many seconds lock will be active. If ttl <= 0, lock will\nbe valid until release. ``Optional`` ``Default: -1`` \\*\n**existing\\_connection\\_pool** already established connection pool\n``Optional`` \\* **redis\\_host** ``Optional`` ``Default: localhost`` \\*\n**redis\\_port** ``Optional`` ``Default: 6379`` \\* **redis\\_password**\n``Optional`` \\* **redis\\_db** ``Optional`` ``Default: 0``\n\n**Basic usage**\n\n.. code:: python\n\n from PyYADL import RedisLock\n\n lock = RedisLock('test_lock')\n lock.acquire()\n lock.release()\n\nBasic lock and release operations. If lock already acquired, will wait\nfor release or ttl expire\n\n.. code:: python\n\n from PyYADL import RedisLock\n\n lock = RedisLock('test_lock')\n with lock:\n # do some tasks\n pass\n\nLock and release using context manager\n\n.. code:: python\n\n from PyYADL import RedisLock\n\n lock1 = RedisLock('test_lock')\n lock2 = RedisLock('test_lock')\n lock1.acquire()\n lock2.release()\n\nWill raise RuntimeError (because lock is owned by other instance)\n\n.. code:: python\n\n from PyYADL import RedisLock\n\n lock1 = RedisLock('test_lock')\n lock2 = RedisLock('test_lock')\n lock1.acquire()\n lock2.release(force=True)\n\nWill release lock, because force parameter is set to True\n\n.. code:: python\n\n from PyYADL import RedisLock\n\n lock = RedisLock('test_lock')\n status = lock.acquire(blocking=False)\n\nWill acquire lock and return True, if lock released, otherwise return\nFalse without waiting\n\n.. code:: python\n\n from PyYADL import RedisLock\n\n lock = RedisLock('test_lock')\n status = lock.acquire(timeout=12)\n\nWill try to acquire lock for 12 seconds. In case of success will return\nTrue, otherwise return False\n\nRead and Write locks\n--------------------\n\nThere are two lock subtypes: \\* Write Lock (typical lock, exclusive) \\*\nRead Lock (non exclusive)\n\nAt the same time, there can be only one write lock (mainly for changes)\nor many read lock (mainly for read operations). If write lock has been\nacquired, read lock cannot be obtained and when at least one read lock\nexists, write lock cannot be acuired.\n\nUsage\n~~~~~\n\nExamples\n^^^^^^^^\n\n.. code:: python\n\n from PyYADL import RedisWriteLock\n\n lock = RedisWriteLock('test_lock')\n status = lock.acquire(blocking=True, timeout=20)\n\nEquivalent of RedisLock class\n\n.. code:: python\n\n from PyYADL import RedisReadLock\n\n lock1 = RedisReadLock('test_lock')\n lock2 = RedisReadLock('test_lock')\n lock1.acquire()\n lock2.acquire()\n\nWill create two read locks (at the same time there can be many read\nlocks)\n\n.. code:: python\n\n from PyYADL import RedisReadLock, RedisWriteLock\n\n lock1 = RedisReadLock('test_lock')\n lock2 = RedisReadLock('test_lock')\n lock3 = RedisWriteLock('test_lock')\n lock1.acquire()\n lock2.acquire()\n lock3.acquire()\n\nWill acquire only lock1 and lock2 (write lock can't be obtained when\nother locks exists)\n\n.. code:: python\n\n from PyYADL import RedisReadLock, RedisWriteLock\n\n lock1 = RedisWriteLock('test_lock')\n lock2 = RedisReadLock('test_lock')\n\n lock1.acquire()\n lock2.acquire()\n\nWill acquire only lock1 (when write lock exists, read lock cannot be\nobtained)\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PawelJ-PL/PyYADL", "keywords": "distributed lock Redis implementation", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "PyYADL", "package_url": "https://pypi.org/project/PyYADL/", "platform": "", "project_url": "https://pypi.org/project/PyYADL/", "project_urls": { "Homepage": "https://github.com/PawelJ-PL/PyYADL" }, "release_url": "https://pypi.org/project/PyYADL/1.0.0/", "requires_dist": [ "redis", "coverage; extra == 'test'", "flake8; extra == 'test'", "nose; extra == 'test'" ], "requires_python": ">=3", "summary": "Yet another distributed lock for python", "version": "1.0.0" }, "last_serial": 3600478, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "60f1035dca9f86f7eafd7bb9860b3fcc", "sha256": "b501fb9b6b01810cdb59af27bb2678b37e74643b582668f1274cd01118e672e9" }, "downloads": -1, "filename": "PyYADL-0.1.0.tar.gz", "has_sig": false, "md5_digest": "60f1035dca9f86f7eafd7bb9860b3fcc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4104, "upload_time": "2017-09-09T09:44:05", "url": "https://files.pythonhosted.org/packages/b4/56/fefde739534865938e980cd70309178082e1e993be6a0631273ca8159843/PyYADL-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "75ea194de68a42551ecae3fb809cffb2", "sha256": "0ef3d402a9c4b6156d08be16136bd480fa86f5b769e40b04c964528e6b146d6c" }, "downloads": -1, "filename": "PyYADL-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "75ea194de68a42551ecae3fb809cffb2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 7077, "upload_time": "2017-09-09T09:52:01", "url": "https://files.pythonhosted.org/packages/c4/64/1e23323238a49de28b463648f03acc19a6d75443a70d6cd1b8a0dec601e1/PyYADL-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8d776a9822e0d76c3cdc1581be3139d5", "sha256": "2a44adc36ea956ada43e8e9b30dabbbaa2833ddf8143e03620256bf6702a812e" }, "downloads": -1, "filename": "PyYADL-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8d776a9822e0d76c3cdc1581be3139d5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5049, "upload_time": "2017-09-09T09:52:02", "url": "https://files.pythonhosted.org/packages/9f/59/059e8b802ca99806f3e1987dce5edfd6a8e5bc4b4c55b8a6a531aa115fb1/PyYADL-0.1.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "5b875837d22f720cf5f48eb7b8bfc1f2", "sha256": "0a245151874e20da60fd35211c98d79ffbb714474fa0f0845cbb7174d0bce662" }, "downloads": -1, "filename": "PyYADL-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5b875837d22f720cf5f48eb7b8bfc1f2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 9514, "upload_time": "2018-02-20T21:58:19", "url": "https://files.pythonhosted.org/packages/ad/bb/7d2db297ef34a98f719caf70eb60603e8cde51d5a00f28ea2f0e9eb01074/PyYADL-1.0.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5b875837d22f720cf5f48eb7b8bfc1f2", "sha256": "0a245151874e20da60fd35211c98d79ffbb714474fa0f0845cbb7174d0bce662" }, "downloads": -1, "filename": "PyYADL-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5b875837d22f720cf5f48eb7b8bfc1f2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 9514, "upload_time": "2018-02-20T21:58:19", "url": "https://files.pythonhosted.org/packages/ad/bb/7d2db297ef34a98f719caf70eb60603e8cde51d5a00f28ea2f0e9eb01074/PyYADL-1.0.0-py3-none-any.whl" } ] }