flufl.lock


Nameflufl.lock JSON
Version 8.1.0 PyPI version JSON
download
home_pageNone
SummaryNFS-safe file locking with timeouts for POSIX and Windows
upload_time2024-03-31 04:35:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseApache-2.0
keywords lock locking locks
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==========
flufl.lock
==========

NFS-safe file locking with timeouts for POSIX and Windows.

The ``flufl.lock`` library provides an NFS-safe file-based locking algorithm
influenced by the GNU/Linux ``open(2)`` manpage, under the description of the
``O_EXCL`` option.

    [...] O_EXCL is broken on NFS file systems, programs which rely on it
    for performing locking tasks will contain a race condition.  The
    solution for performing atomic file locking using a lockfile is to
    create a unique file on the same fs (e.g., incorporating hostname and
    pid), use link(2) to make a link to the lockfile.  If link() returns
    0, the lock is successful.  Otherwise, use stat(2) on the unique file
    to check if its link count has increased to 2, in which case the lock
    is also successful.

The assumption made here is that there will be no *outside interference*,
e.g. no agent external to this code will ever ``link()`` to the specific lock
files used.

Lock objects support lock-breaking so that you can't wedge a process forever.
This is especially helpful in a web environment, but may not be appropriate
for all applications.

Locks have a *lifetime*, which is the maximum length of time the process
expects to retain the lock.  It is important to pick a good number here
because other processes will not break an existing lock until the expected
lifetime has expired.  Too long and other processes will hang; too short and
you'll end up trampling on existing process locks -- and possibly corrupting
data.  In a distributed (NFS) environment, you also need to make sure that
your clocks are properly synchronized.


Author
======

``flufl.lock`` is Copyright (C) 2007-2024 Barry Warsaw <barry@python.org>

Licensed under the terms of the Apache License Version 2.0.  See the LICENSE
file for details.


Project details
===============

 * Project home: https://gitlab.com/warsaw/flufl.lock
 * Report bugs at: https://gitlab.com/warsaw/flufl.lock/issues
 * Code hosting: https://gitlab.com/warsaw/flufl.lock.git
 * Documentation: https://flufllock.readthedocs.io/
 * PyPI: https://pypi.python.org/pypi/flufl.lock

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "flufl.lock",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "lock, locking, locks",
    "author": null,
    "author_email": "Barry Warsaw <barry@python.org>",
    "download_url": "https://files.pythonhosted.org/packages/a9/fa/885c58f9716063e2ac099f773d0420f20bb834b19538066a2e0d5b848ba4/flufl_lock-8.1.0.tar.gz",
    "platform": null,
    "description": "==========\nflufl.lock\n==========\n\nNFS-safe file locking with timeouts for POSIX and Windows.\n\nThe ``flufl.lock`` library provides an NFS-safe file-based locking algorithm\ninfluenced by the GNU/Linux ``open(2)`` manpage, under the description of the\n``O_EXCL`` option.\n\n    [...] O_EXCL is broken on NFS file systems, programs which rely on it\n    for performing locking tasks will contain a race condition.  The\n    solution for performing atomic file locking using a lockfile is to\n    create a unique file on the same fs (e.g., incorporating hostname and\n    pid), use link(2) to make a link to the lockfile.  If link() returns\n    0, the lock is successful.  Otherwise, use stat(2) on the unique file\n    to check if its link count has increased to 2, in which case the lock\n    is also successful.\n\nThe assumption made here is that there will be no *outside interference*,\ne.g. no agent external to this code will ever ``link()`` to the specific lock\nfiles used.\n\nLock objects support lock-breaking so that you can't wedge a process forever.\nThis is especially helpful in a web environment, but may not be appropriate\nfor all applications.\n\nLocks have a *lifetime*, which is the maximum length of time the process\nexpects to retain the lock.  It is important to pick a good number here\nbecause other processes will not break an existing lock until the expected\nlifetime has expired.  Too long and other processes will hang; too short and\nyou'll end up trampling on existing process locks -- and possibly corrupting\ndata.  In a distributed (NFS) environment, you also need to make sure that\nyour clocks are properly synchronized.\n\n\nAuthor\n======\n\n``flufl.lock`` is Copyright (C) 2007-2024 Barry Warsaw <barry@python.org>\n\nLicensed under the terms of the Apache License Version 2.0.  See the LICENSE\nfile for details.\n\n\nProject details\n===============\n\n * Project home: https://gitlab.com/warsaw/flufl.lock\n * Report bugs at: https://gitlab.com/warsaw/flufl.lock/issues\n * Code hosting: https://gitlab.com/warsaw/flufl.lock.git\n * Documentation: https://flufllock.readthedocs.io/\n * PyPI: https://pypi.python.org/pypi/flufl.lock\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "NFS-safe file locking with timeouts for POSIX and Windows",
    "version": "8.1.0",
    "project_urls": {
        "Bug Tracker": "https://gitlab.com/warsaw/flufl.lock/issues",
        "Documentation": "https://flufllock.readthedocs.io",
        "Home Page": "https://flufllock.readthedocs.io",
        "Source Code": "https://gitlab.com/warsaw/flufl.lock.git"
    },
    "split_keywords": [
        "lock",
        " locking",
        " locks"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2036e6b26dc9ace9f4fa30f46b3f69182b6f25c07746e0b71caf3cc3c4d78ed2",
                "md5": "10b86a5d2e9aca4ad8714c862e32255e",
                "sha256": "a01b2153d1b0cc170a26b1413037debbe94af6a1cd23164b3b2b229f766b164f"
            },
            "downloads": -1,
            "filename": "flufl_lock-8.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "10b86a5d2e9aca4ad8714c862e32255e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11143,
            "upload_time": "2024-03-31T04:35:12",
            "upload_time_iso_8601": "2024-03-31T04:35:12.613824Z",
            "url": "https://files.pythonhosted.org/packages/20/36/e6b26dc9ace9f4fa30f46b3f69182b6f25c07746e0b71caf3cc3c4d78ed2/flufl_lock-8.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a9fa885c58f9716063e2ac099f773d0420f20bb834b19538066a2e0d5b848ba4",
                "md5": "03489ca6897b84761a610df91a7c2acd",
                "sha256": "d88302005692a63d98b60080158faf089be5ecae6969f706409da8276fdce7cb"
            },
            "downloads": -1,
            "filename": "flufl_lock-8.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "03489ca6897b84761a610df91a7c2acd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 32884,
            "upload_time": "2024-03-31T04:35:14",
            "upload_time_iso_8601": "2024-03-31T04:35:14.409749Z",
            "url": "https://files.pythonhosted.org/packages/a9/fa/885c58f9716063e2ac099f773d0420f20bb834b19538066a2e0d5b848ba4/flufl_lock-8.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-31 04:35:14",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "warsaw",
    "gitlab_project": "flufl.lock",
    "lcname": "flufl.lock"
}
        
Elapsed time: 0.52249s