{ "info": { "author": "Daniel Fairhead", "author_email": "danthedeckie@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries", "Topic :: System :: Systems Administration" ], "description": "=========\nOnly Once\n=========\n\nA simple Lock Dir system. Creating Dirs is atomic, which is useful for\nlocking things to only let one version of a process start.\n\nA directory is created, say called 'lock'.\nInside this directory will be a PID file, which keeps the PID of the running process.\nIf the process dies, or is killed, then the whole directory will be deleted, allowing\nthe task to be run again later, and not leaving clutter around the place.\n\n------\nUsage:\n------\n\nBasic usage should be as simple as ::\n\n try:\n with onlyonce.SingleProcessLock('/tmp/lock') as lock:\n lock.run(['rsync', '-avz', '/here', 'there'])\n except onlyonce.StillRunning as err:\n print str(err)\n\nif you want to do something special with running the task (redirecting output, etc)\nthen you can use lock.run with the same arguments as subprocess.Popen (they'll all get\npassed through). So: ::\n\n lock.run(['rsync','...'], stderr=...)\n\nShould work fine.\n\nIf you *dont* want to block and wait for the process to finish, then you'll need to\ngo a bit more low level: ::\n\n\n try:\n with onlyonce.SingleProcessLock('/tmp/lock') as lock:\n process = Popen(['rsync', '-avz', '/here', 'there'], stderr=whatever ...)\n lock.write_pid(process.pid)\n except ...\n\nWhich doesn't block.\n\n------\nNotes:\n------\n\nYou can 'kill' the task, and onlyonce will clean up the lock dir for you. If you 'kill -9' the\nscript, however, python freaks out and quits before the script can do anything. Sorry!\n\nThis system is NOT designed to replace large daemonising clever init/systemd whatever stuff.\nIt was written simply to let us run rsync & other processess around the campus without\nit being possible for multiple versions of the script to be running at once.\n\nIdeally, you should only be running ONE process with this at a time.\n\nHave fun. :-)", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/danthedeckie/onlyonce/tarball/0.0.3", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/danthedeckie/onlyonce", "keywords": "Files,Process Locking,Scripting", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "onlyonce", "package_url": "https://pypi.org/project/onlyonce/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/onlyonce/", "project_urls": { "Download": "https://github.com/danthedeckie/onlyonce/tarball/0.0.3", "Homepage": "https://github.com/danthedeckie/onlyonce" }, "release_url": "https://pypi.org/project/onlyonce/0.0.3/", "requires_dist": null, "requires_python": null, "summary": "Small Python lib for running scripts once and once only (with file locks, etc)", "version": "0.0.3" }, "last_serial": 907483, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "26984765c5ad9a02ebce8db5f5817916", "sha256": "63bee74ceb9088d83611c557f0aa948c9b4526cecf7eb3a12e011b971e7e8d57" }, "downloads": -1, "filename": "onlyonce-0.0.2.tar.gz", "has_sig": false, "md5_digest": "26984765c5ad9a02ebce8db5f5817916", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3776, "upload_time": "2013-10-30T15:40:12", "url": "https://files.pythonhosted.org/packages/3b/c5/23f32d769ed63a4c9bad2288d09af7fce86183f4aac5ee04772b16d5b84a/onlyonce-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "910ac18635110dc17b6cd48a6d9cf385", "sha256": "0ae78a5d6040a806529cdf8b463893339bf5ad38eac315d91089f8019f701e23" }, "downloads": -1, "filename": "onlyonce-0.0.3.tar.gz", "has_sig": false, "md5_digest": "910ac18635110dc17b6cd48a6d9cf385", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4048, "upload_time": "2013-10-30T16:17:40", "url": "https://files.pythonhosted.org/packages/05/41/413b83bdfce9902f76923be7211fe153080c8987b6d3ba28bb64e4b9a9f1/onlyonce-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "910ac18635110dc17b6cd48a6d9cf385", "sha256": "0ae78a5d6040a806529cdf8b463893339bf5ad38eac315d91089f8019f701e23" }, "downloads": -1, "filename": "onlyonce-0.0.3.tar.gz", "has_sig": false, "md5_digest": "910ac18635110dc17b6cd48a6d9cf385", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4048, "upload_time": "2013-10-30T16:17:40", "url": "https://files.pythonhosted.org/packages/05/41/413b83bdfce9902f76923be7211fe153080c8987b6d3ba28bb64e4b9a9f1/onlyonce-0.0.3.tar.gz" } ] }