numba-cache-lock


Namenumba-cache-lock JSON
Version 0.1.0a2 PyPI version JSON
download
home_pageNone
SummaryA caching system for Numba with file locking support
upload_time2025-07-14 20:35:24
maintainerNone
docs_urlNone
authorGuilherme Leobas
requires_python>=3.9
licenseNone
keywords numba caching
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # numba-lock-cache

A Python package that monkey-patches Numba's caching mechanism to safely coordinate concurrent cache access using file locks.

## Why?

Numba’s function-level caching (`@jit(cache=True)`) is not concurrency-safe by default. This can lead to:

- Crashes when multiple processes load/write to the same cache
- Especially problematic on shared filesystems (e.g., NFS)

## Locking Mechanism

- Uses [`flufl.lock`](https://pypi.org/project/flufl.lock/) for file-based locking.
- Lock file is created next to the cache index file:
  `/path/to/cache/func.nbi.lock`
- Lock behavior:
  - Timeout to acquire: 60 minutes (configurable)
  - Lifetime: `None` (lock persists until released)
  - NFS-safe: relies on atomic file creation

## Installation

```bash
pip install numba-lock-cache
```

## How to use it

Just import the patch Numba in your application:

```python
import numba_cache_lock

numba_cache_lock.patch_numba_cache()

from numba import jit

@jit(cache=True)
def my_func(x):
    return x * 2
```

By default, `patch_numba_cache` will hold a lock for 1 hour in the worst case.
One can change this value by assigning the `lifetime=` keyword argument to a
`timedelta` object.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "numba-cache-lock",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "numba, caching",
    "author": "Guilherme Leobas",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/e7/42/66c2bf259487edc90e1da2bddc15b6cc216d12a61a6eca535807a6a908d2/numba_cache_lock-0.1.0a2.tar.gz",
    "platform": null,
    "description": "# numba-lock-cache\n\nA Python package that monkey-patches Numba's caching mechanism to safely coordinate concurrent cache access using file locks.\n\n## Why?\n\nNumba\u2019s function-level caching (`@jit(cache=True)`) is not concurrency-safe by default. This can lead to:\n\n- Crashes when multiple processes load/write to the same cache\n- Especially problematic on shared filesystems (e.g., NFS)\n\n## Locking Mechanism\n\n- Uses [`flufl.lock`](https://pypi.org/project/flufl.lock/) for file-based locking.\n- Lock file is created next to the cache index file:\n  `/path/to/cache/func.nbi.lock`\n- Lock behavior:\n  - Timeout to acquire: 60 minutes (configurable)\n  - Lifetime: `None` (lock persists until released)\n  - NFS-safe: relies on atomic file creation\n\n## Installation\n\n```bash\npip install numba-lock-cache\n```\n\n## How to use it\n\nJust import the patch Numba in your application:\n\n```python\nimport numba_cache_lock\n\nnumba_cache_lock.patch_numba_cache()\n\nfrom numba import jit\n\n@jit(cache=True)\ndef my_func(x):\n    return x * 2\n```\n\nBy default, `patch_numba_cache` will hold a lock for 1 hour in the worst case.\nOne can change this value by assigning the `lifetime=` keyword argument to a\n`timedelta` object.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A caching system for Numba with file locking support",
    "version": "0.1.0a2",
    "project_urls": {
        "Home": "https://github.com/Quansight/numba-cache-lock",
        "Source": "https://github.com/Quansight/numba-cache-lock"
    },
    "split_keywords": [
        "numba",
        " caching"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b25fcfc3836e01bd7025f6df1ba70f41aee5fecdeb5dd102fe720ebaa4eb7b1a",
                "md5": "ca15f2fc0213ea0034a8bcfabfe86bda",
                "sha256": "f626e77faac3c77f19c471b720f64a460d6941d6c83733bb5b1e754d4267ff2e"
            },
            "downloads": -1,
            "filename": "numba_cache_lock-0.1.0a2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca15f2fc0213ea0034a8bcfabfe86bda",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 3331,
            "upload_time": "2025-07-14T20:35:24",
            "upload_time_iso_8601": "2025-07-14T20:35:24.144573Z",
            "url": "https://files.pythonhosted.org/packages/b2/5f/cfc3836e01bd7025f6df1ba70f41aee5fecdeb5dd102fe720ebaa4eb7b1a/numba_cache_lock-0.1.0a2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e74266c2bf259487edc90e1da2bddc15b6cc216d12a61a6eca535807a6a908d2",
                "md5": "2213265469b28b20cb99d7696ec9dfd8",
                "sha256": "45f274356771ac3c8dbb3ee8a3ee27ba39769b25218ed1734c7e7c2b09bf52fb"
            },
            "downloads": -1,
            "filename": "numba_cache_lock-0.1.0a2.tar.gz",
            "has_sig": false,
            "md5_digest": "2213265469b28b20cb99d7696ec9dfd8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 2812,
            "upload_time": "2025-07-14T20:35:24",
            "upload_time_iso_8601": "2025-07-14T20:35:24.849342Z",
            "url": "https://files.pythonhosted.org/packages/e7/42/66c2bf259487edc90e1da2bddc15b6cc216d12a61a6eca535807a6a908d2/numba_cache_lock-0.1.0a2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-14 20:35:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Quansight",
    "github_project": "numba-cache-lock",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "numba-cache-lock"
}
        
Elapsed time: 0.51253s