{ "info": { "author": "Raghu Udiyar", "author_email": "raghusiddarth@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Lockpick\n\nLockpick is an utility for distributed locking using zookeeper. Its intended to be used in distributed environments where scripts need synchronization between runs.\n\nAt Helpshift, its primarily used for parallel and lockless autoscaling.\n\n# Why Lockpick\n\nLockpick uses the kazoo library but provides following benefits over kazoo recipes :\n\n* Use non ephemeral zknode to allow *explicit* lock release\n* Exits with correct return codes\n* Correct signal Handling and cleanup\n* Retires and timeout\n\n## Usage\n\n```shell\n$ lockpick --help\nusage: lockpick [-h] [-s SERVERS] [-c CHROOT] [-i IDENTIFIER] [-v]\n [-r RETRY_COUNT] [-p RETRY_SLEEP]\n {lock,rlock,wlock,unlock,list} lock_path\n\nDistributed locking using Zookeeper primarily for scripting. After acquiring\nthe lock, the zk node is printed to STDOUT. This zk node should be passed to\nunlock. Note: all logs are printed to STDERR\n\npositional arguments:\n {lock,rlock,wlock,unlock,list}\n lock: acquire a mutex lock. rlock: acquire a read lock\n wlock: acquire a write lock. unlock: release lock\n identified by zk node. list: list all lock contenders\n lock_path ZK path to lock OR ZK node to unlock. For the\n unlockaction this must be the chrooted zk path to the\n node e.g.lockpick lock -c /devops /mylocklockpick\n unlock -c /devops /mylock/9d2badeec7684f35b10f4860db42\n e45c__rlock__0000000022\n\noptional arguments:\n -h, --help show this help message and exit\n -s SERVERS, --servers SERVERS\n -c CHROOT, --chroot CHROOT\n ZK chroot for the lock path\n -i IDENTIFIER, --identifier IDENTIFIER\n Optional string identifier to add to the lock node OR\n verify when unlocking\n -v, --verbose\n -r RETRY_COUNT, --retry-count RETRY_COUNT\n -p RETRY_SLEEP, --retry-sleep RETRY_SLEEP\n```\n\n## Install\n\nWe recommend using pip to install in a virtualenv :\n\n```\n$ virtualenv lockpick\n$ pip install lockpick-hsft\n```\n\n## Example\n\n```console\n$ lockpick -s localhost:2181 -c /test -i \"test lock1\" rlock /mylock\n/mylock/503e61fadc8f492497db823b87e64afe__rlock__0000000038\n\n$ lockpick -s localhost:2181 -c /test -i \"test lock1\" rlock /mylock\n/mylock/e21b0ecd480346aaaba23e77946e16e9__rlock__0000000039\n\n$ lockpick -s localhost:2181 -c /test -i \"test lock1\" list /mylock\n'test lock1' /mylock/e21b0ecd480346aaaba23e77946e16e9__rlock__0000000039\n'test lock1' /mylock/503e61fadc8f492497db823b87e64afe__rlock__0000000038\n\n$ lockpick -s localhost:2181 -c /test -i \"test lock1\" wlock /mylock\n[2018-07-25 19:09:53,095] WARNING lockpick: Waiting to acquire lock, contenders are :\n[2018-07-25 19:09:53,103] WARNING lockpick: 'test lock1' /mylock/e21b0ecd480346aaaba23e77946e16e9__rlock__0000000039\n[2018-07-25 19:09:53,103] WARNING lockpick: 'test lock1' /mylock/503e61fadc8f492497db823b87e64afe__rlock__0000000038\n[2018-07-25 19:09:53,104] WARNING lockpick: 'test lock1' /mylock/492b4a6c1727417daf511b343d0d11b7__lock__0000000042\n[2018-07-25 19:09:56,104] WARNING lockpick: Waiting to acquire lock, contenders are :\n[2018-07-25 19:09:56,114] WARNING lockpick: 'test lock1' /mylock/e21b0ecd480346aaaba23e77946e16e9__rlock__0000000039\n[2018-07-25 19:09:56,114] WARNING lockpick: 'test lock1' /mylock/503e61fadc8f492497db823b87e64afe__rlock__0000000038\n[2018-07-25 19:09:56,114] WARNING lockpick: 'test lock1' /mylock/492b4a6c1727417daf511b343d0d11b7__lock__0000000042\n[2018-07-25 19:09:59,116] WARNING lockpick: LockTimeout exception rasied by locker thread\n[2018-07-25 19:09:59,117] ERROR lockpick: Failed to acquire lock within timeout!\n\n$ lockpick -s localhost:2181 -c /test -i \"test lock1\" unlock /mylock/503e61fadc8f492497db823b87e64afe__rlock__0000000038\n\n$ lockpick -s localhost:2181 -c /test -i \"test lock1\" unlock /mylock/e21b0ecd480346aaaba23e77946e16e9__rlock__0000000039\n\n$ lockpick -s localhost:2181 -c /test -i \"test lock1\" wlock /mylock\n/mylock/d6602d4a54124826b27c50a43ab67a5e__lock__0000000043\n```\n\n## syncd_spawn.sh\n\nSpawns the given command only if it can acquire the given lock.\n\n```console\n./syncd_spawn -n /test -C 'test' -l rlock sleep 5\nGot lock on /test\nRunning your command sleep 5\nUnlocked '/test/141bcfad04c6459591164ea12d1604af__rlock__0000000011'\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/helpshift/lockpick", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "lockpick-hsft", "package_url": "https://pypi.org/project/lockpick-hsft/", "platform": "", "project_url": "https://pypi.org/project/lockpick-hsft/", "project_urls": { "Homepage": "https://github.com/helpshift/lockpick" }, "release_url": "https://pypi.org/project/lockpick-hsft/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Utility for distributed locking using Zookeeper", "version": "0.1.1" }, "last_serial": 4135294, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "b047c5370d5e741c173a4b37630b6fb8", "sha256": "0ea8da09cabf674ae3c55367928efd9d511e0443c0dcb45d35ad9e32a2fdd9c6" }, "downloads": -1, "filename": "lockpick-hsft-0.1.0.tar.gz", "has_sig": false, "md5_digest": "b047c5370d5e741c173a4b37630b6fb8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4344, "upload_time": "2018-08-04T11:06:34", "url": "https://files.pythonhosted.org/packages/bb/3b/f5fd16b3a70f6f043e4aa70edaa8a04e91cbde8c265c250747b673c55fa9/lockpick-hsft-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "fde9fe1d3a79aa1fba7c1cd7479f9e31", "sha256": "c50928e46756f8266e9ab47c5172a0e1416d69c5d9c58efae31a626f2d0de043" }, "downloads": -1, "filename": "lockpick-hsft-0.1.1.tar.gz", "has_sig": false, "md5_digest": "fde9fe1d3a79aa1fba7c1cd7479f9e31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4797, "upload_time": "2018-08-04T11:14:41", "url": "https://files.pythonhosted.org/packages/1c/11/e8c25a11f54255d85a87583bb80d5506861e55e2f30c42d42315b586b387/lockpick-hsft-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fde9fe1d3a79aa1fba7c1cd7479f9e31", "sha256": "c50928e46756f8266e9ab47c5172a0e1416d69c5d9c58efae31a626f2d0de043" }, "downloads": -1, "filename": "lockpick-hsft-0.1.1.tar.gz", "has_sig": false, "md5_digest": "fde9fe1d3a79aa1fba7c1cd7479f9e31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4797, "upload_time": "2018-08-04T11:14:41", "url": "https://files.pythonhosted.org/packages/1c/11/e8c25a11f54255d85a87583bb80d5506861e55e2f30c42d42315b586b387/lockpick-hsft-0.1.1.tar.gz" } ] }