{ "info": { "author": "Silvano Buback", "author_email": "snbuback@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Distributed Lock\n=======================\n\nPython distributed lock (currently only with memcached)\n\nHow to configure\n------------------------\n\nIn your setup file (in django, settings.py), configure locking:\n\n```python\nimport distributedlock\ndistributedlock.DEFAULT_MEMCACHED_CLIENT = memcache.Client(['127.0.0.1:11211'])\ndistributedlock.DEFAULT_TIMEOUT=60\ndistributedlock.DEFAULT_BLOCKING=False\n```\n\nIf you setting up memcached in Django, you can use it abstraction of memcached.\n\n```python\nfrom django.core.cache import cache\ndistributedlock.DEFAULT_MEMCACHED_CLIENT = cache\n```\n\nYou can configure this settings in each lock, as parameter.\n\n\nHow to use\n------------------------\n\nUsing minimal configuration, as decorator:\n\n```python\nfrom distributedlock import distributedlock\n@distributedlock()\ndef hello_world():\n print 'running'\n```\n\nOr as `with` block:\n\n```python\nfrom distributedlock import distributedlock\n\n#... my code before\nwith distributedlock('hello'):\n print 'running'\n#... my code after\n```\n\nYou can use with conventional threading.Lock (only in process locking)\n\n```python\nimport threading\nwith distributedlock('hello', lock=threading.Lock())\n print 'running'\n```\n\nArguments\n------------------------\n\n```python\ndef distributedlock(key, lock=None, blocking=None)\n```\n\n * key: name of key in memcached. Avoid long names, because memcached supports only 255 characters in key. Using decorator\n key name will be class name + method name if not specified.\n * lock: If you desire use another lock strategy, like `threading.Lock()` or `threading.RLock()`. defaults to `distributedlock.memcachedlock.MemcachedLock`\n * blocking: If another process has lock, wait until have a lock or abort immediately, raising `LockNotAcquiredError`. Defaults to `distributedlock.DEFAULT_BLOCKING`\n\nTips\n------------------------\n\n * If you have a dynamic key, use lock with block to compose your key. For example:\n \n```python\ndef synchronized_method(arg1)\n with distributedlock('sync_process_%d' % arg1.id):\n # do something\n```", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/snbuback/DistributedLock", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "DistributedLock", "package_url": "https://pypi.org/project/DistributedLock/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/DistributedLock/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/snbuback/DistributedLock" }, "release_url": "https://pypi.org/project/DistributedLock/1.2/", "requires_dist": null, "requires_python": null, "summary": "Python Distributed Lock with memcached support", "version": "1.2" }, "last_serial": 784119, "releases": { "1.0": [], "1.1": [ { "comment_text": "", "digests": { "md5": "914ca2399fe2b956849a330baa3b08cd", "sha256": "9eb9f7bbaeb73abb69fe027efecee06df7e1407761e20700df2c2abc89631ae8" }, "downloads": -1, "filename": "DistributedLock-1.1.tar.gz", "has_sig": false, "md5_digest": "914ca2399fe2b956849a330baa3b08cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3068, "upload_time": "2013-01-16T22:46:45", "url": "https://files.pythonhosted.org/packages/16/11/9b3abde77eb3677a840b1a1a7ddf277c154f25a1a6752a6284b7366a818e/DistributedLock-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "80e5c533923042835e748d6de4a81bd6", "sha256": "18fcf4127383122d0be6ea2dddc745296a13e2a9691019f3c97bc0c6b33680cd" }, "downloads": -1, "filename": "DistributedLock-1.2.tar.gz", "has_sig": false, "md5_digest": "80e5c533923042835e748d6de4a81bd6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3504, "upload_time": "2013-01-17T18:47:02", "url": "https://files.pythonhosted.org/packages/1e/65/2cdd9dbc8707bd197fd8a9823b19c86f8904203363c90ba16e6f66b4bc23/DistributedLock-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "80e5c533923042835e748d6de4a81bd6", "sha256": "18fcf4127383122d0be6ea2dddc745296a13e2a9691019f3c97bc0c6b33680cd" }, "downloads": -1, "filename": "DistributedLock-1.2.tar.gz", "has_sig": false, "md5_digest": "80e5c533923042835e748d6de4a81bd6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3504, "upload_time": "2013-01-17T18:47:02", "url": "https://files.pythonhosted.org/packages/1e/65/2cdd9dbc8707bd197fd8a9823b19c86f8904203363c90ba16e6f66b4bc23/DistributedLock-1.2.tar.gz" } ] }