safelock


Namesafelock JSON
Version 1.3.3 PyPI version JSON
download
home_pagehttps://codeberg.org/topdevpros/safelock
SummarySafelock gives you simple systemwide multithread, multiprocess, multiprogram locks.
upload_time2023-12-31 08:07:38
maintainertopdevpros
docs_urlNone
authorTopDevPros
requires_python>=3.5
licenseGNU General Public License v3 (GPLv3)
keywords locks multiprocess multithread multiinstance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Safelock
---------

Mutually exclusive locks are usually the simplest way to get safe concurrent access to a shared resource. But implementing the locks is a bear to get right. Get simple systemwide multithread, multiprocess, and multiprogram safe locks.


Description
-----------

Multithreading Concurrency in Python Solved

When you first try python multithreading and access a database, it usually works. That's because databases have some concurrency built in. With any other shared resource, your program frequently crashes. Concurrency is hard. Safelock makes it easy.

Start as many threads, subprocesses, or programs as you like. When they try to access a shared resource, Safelock only lets one run at a time.


Install
-------

sudo pip3 install safelock

If you are installing Safelock from codeberg.org, be sure to also install the "safelog" package.


Updates
-------

All future updates will only be available from:

    git clone https://codeberg.org/topdevpros/safelock.git


How it Works
-----------

Safelock includes a small server that must run as root. See Configuration to learn how to start the server.

In any python code that you want locked,

   from solidlibs.os.lock import locked

    with locked():
        ... your locked code ...

It's that easy.

You access the shared resource only in your locked code. No matter how many threads, subprocesses, or separate programs enter your locked code, Safelock only lets one run at a time. So only one job gets the resource at a time.

 Safelock manages python multithreading concurrency

No more crashes caused by resource conflict.

Complex apps frequently require access to the same resources at the same time. This can cause serious contention which slows down an app or crashes it. The python standard library provides some resource sharing, but it's very hard to get it right. Safelock makes it simple.

Safelock retries the lock automatically for you. If the lock times out, your app must decide whether to try again.

If you need to access a shared resource from multiple places in your code, always get the lock for that resource from a single function. Example:

        def my_locked_resource():
            return locked():


Then every time you need access to the shared resource:

        with my_locked_resource():
            ... your locked code ...


Using syncronized locks is usually the simplest way to get safe concurrent access to a shared resource. But implementing the locks is a bear to get right. Get simple systemwide multithread, multiprocess, and multiprogram safe locks.

Safelock automatically creates and manages a separate system-wide lock for every locked context block.


Configuration
-------------

Safelock uses Safelog. Both are installed when you install Safelock regardless which install method you use. Both include small servers to manage system-wide access.

The safelock and safelog commands installed in /usr/bin. The safelock and safelog servers must run as root.

You can start the servers automatically with systemd. Get the service files:

    safelock.service
    safelog.service

Then:

        systemctl enable MYPATH/safelog.service
        systemctl start safelog
        systemctl enable MYPATH/safelock.service
        systemctl start safelock

MYPATH is the directory where you saved the service files.

If you don't use systemd, start both servers by hand:

        safelog &
        safelock &


You're ready to use safelock.

Manage your python multithreading concurrency with simple locks. Get Safelock.

            

Raw data

            {
    "_id": null,
    "home_page": "https://codeberg.org/topdevpros/safelock",
    "name": "safelock",
    "maintainer": "topdevpros",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "locks multiprocess multithread multiinstance",
    "author": "TopDevPros",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/37/9a/b102b08015329cd47c86453f1bd3cb000051d31d4fa64defecbe5573fdd7/safelock-1.3.3.tar.gz",
    "platform": null,
    "description": "Safelock\n---------\n\nMutually exclusive locks are usually the simplest way to get safe concurrent access to a shared resource. But implementing the locks is a bear to get right. Get simple systemwide multithread, multiprocess, and multiprogram safe locks.\n\n\nDescription\n-----------\n\nMultithreading Concurrency in Python Solved\n\nWhen you first try python multithreading and access a database, it usually works. That's because databases have some concurrency built in. With any other shared resource, your program frequently crashes. Concurrency is hard. Safelock makes it easy.\n\nStart as many threads, subprocesses, or programs as you like. When they try to access a shared resource, Safelock only lets one run at a time.\n\n\nInstall\n-------\n\nsudo pip3 install safelock\n\nIf you are installing Safelock from codeberg.org, be sure to also install the \"safelog\" package.\n\n\nUpdates\n-------\n\nAll future updates will only be available from:\n\n    git clone https://codeberg.org/topdevpros/safelock.git\n\n\nHow it Works\n-----------\n\nSafelock includes a small server that must run as root. See Configuration to learn how to start the server.\n\nIn any python code that you want locked,\n\n   from solidlibs.os.lock import locked\n\n    with locked():\n        ... your locked code ...\n\nIt's that easy.\n\nYou access the shared resource only in your locked code. No matter how many threads, subprocesses, or separate programs enter your locked code, Safelock only lets one run at a time. So only one job gets the resource at a time.\n\n Safelock manages python multithreading concurrency\n\nNo more crashes caused by resource conflict.\n\nComplex apps frequently require access to the same resources at the same time. This can cause serious contention which slows down an app or crashes it. The python standard library provides some resource sharing, but it's very hard to get it right. Safelock makes it simple.\n\nSafelock retries the lock automatically for you. If the lock times out, your app must decide whether to try again.\n\nIf you need to access a shared resource from multiple places in your code, always get the lock for that resource from a single function. Example:\n\n        def my_locked_resource():\n            return locked():\n\n\nThen every time you need access to the shared resource:\n\n        with my_locked_resource():\n            ... your locked code ...\n\n\nUsing syncronized locks is usually the simplest way to get safe concurrent access to a shared resource. But implementing the locks is a bear to get right. Get simple systemwide multithread, multiprocess, and multiprogram safe locks.\n\nSafelock automatically creates and manages a separate system-wide lock for every locked context block.\n\n\nConfiguration\n-------------\n\nSafelock uses Safelog. Both are installed when you install Safelock regardless which install method you use. Both include small servers to manage system-wide access.\n\nThe safelock and safelog commands installed in /usr/bin. The safelock and safelog servers must run as root.\n\nYou can start the servers automatically with systemd. Get the service files:\n\n    safelock.service\n    safelog.service\n\nThen:\n\n        systemctl enable MYPATH/safelog.service\n        systemctl start safelog\n        systemctl enable MYPATH/safelock.service\n        systemctl start safelock\n\nMYPATH is the directory where you saved the service files.\n\nIf you don't use systemd, start both servers by hand:\n\n        safelog &\n        safelock &\n\n\nYou're ready to use safelock.\n\nManage your python multithreading concurrency with simple locks. Get Safelock.\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 (GPLv3)",
    "summary": "Safelock gives you simple systemwide multithread, multiprocess, multiprogram locks.",
    "version": "1.3.3",
    "project_urls": {
        "Download": "https://codeberg.org/topdevpros/safelock.git",
        "Homepage": "https://codeberg.org/topdevpros/safelock",
        "Source Code": "https://codeberg.org/topdevpros/safelock/src/branch/main/source"
    },
    "split_keywords": [
        "locks",
        "multiprocess",
        "multithread",
        "multiinstance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "827a2666a8b2767cb70889a4583f4d5e97abfee51e13b2dcdfbf7eaeff5a51d6",
                "md5": "c98f1d3d3e716853c5089e67c46b5e86",
                "sha256": "5c74486b6facacc125c605f814e5b0357e222cee770d46e6cc59a38b57c63a42"
            },
            "downloads": -1,
            "filename": "safelock-1.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c98f1d3d3e716853c5089e67c46b5e86",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 6064,
            "upload_time": "2023-12-31T08:07:36",
            "upload_time_iso_8601": "2023-12-31T08:07:36.556458Z",
            "url": "https://files.pythonhosted.org/packages/82/7a/2666a8b2767cb70889a4583f4d5e97abfee51e13b2dcdfbf7eaeff5a51d6/safelock-1.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "379ab102b08015329cd47c86453f1bd3cb000051d31d4fa64defecbe5573fdd7",
                "md5": "9a3f375e44ad344e6ba1055c2ec93876",
                "sha256": "324ebe62ff1432073dbd67ee8fec2c6b09258655b64505d9acff741da2e52efc"
            },
            "downloads": -1,
            "filename": "safelock-1.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "9a3f375e44ad344e6ba1055c2ec93876",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 6167,
            "upload_time": "2023-12-31T08:07:38",
            "upload_time_iso_8601": "2023-12-31T08:07:38.385746Z",
            "url": "https://files.pythonhosted.org/packages/37/9a/b102b08015329cd47c86453f1bd3cb000051d31d4fa64defecbe5573fdd7/safelock-1.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-31 08:07:38",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": true,
    "codeberg_user": "topdevpros",
    "codeberg_project": "safelock",
    "lcname": "safelock"
}
        
Elapsed time: 0.17159s