overdue


Nameoverdue JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryEasy timeout actions for any Python code with contextmanagers or decorators
upload_time2024-12-17 19:20:19
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License
keywords error-handling exception performance scalability timeout
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Overdue
Conveniently stop Python code from running when it is taking too long on Python 3.10+.
Ships with type annotations and depends at runtime on nothing but Python itself.

For older Pythons, consider [stopit](https://github.com/glenfant/stopit).

## Installation
`$ pip install overdue` or whatever is the equivalent in your favorite package manager.

## Using a context manager
Without exceptions:
```python
from overdue import timeout_set_to

with timeout_set_to(0.25) as timeout:
    # Slow code
if timeout.triggered:
    # Handle timeout
```
With an exception:
```python
from datetime import timedelta
from overdue import timeout_set_to, TaskAbortedError

try:
    with timeout_set_to(timedelta(milliseconds=250), raise_exception=True):
        # Slow code
except TaskAbortedError:
    # Handle timeout
```

## Using a decorator
With an exception:
```python
from overdue import timecapped_to, TaskAbortedError

@timecapped_to(0.25)
def my_slow_function() -> None:
    # Slow code

try:
    my_slow_function()
except TaskAbortedError:
    # Handle timeout
```

Without exceptions:
```python
from overdue import in_time_or_none

@in_time_or_none(0.25)
def my_slow_function() -> int:
    # Slow code
    return 7

if (result := my_slow_function()) is None:
    # Handle timeout
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "overdue",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "error-handling, exception, performance, scalability, timeout",
    "author": null,
    "author_email": "Antti Kajander <9019523+kajaste@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/0f/28/7a099f4f699c23b0b7701a9901325b4fd1c3812bb45be9438f97a16d25ed/overdue-0.1.5.tar.gz",
    "platform": null,
    "description": "# Overdue\nConveniently stop Python code from running when it is taking too long on Python 3.10+.\nShips with type annotations and depends at runtime on nothing but Python itself.\n\nFor older Pythons, consider [stopit](https://github.com/glenfant/stopit).\n\n## Installation\n`$ pip install overdue` or whatever is the equivalent in your favorite package manager.\n\n## Using a context manager\nWithout exceptions:\n```python\nfrom overdue import timeout_set_to\n\nwith timeout_set_to(0.25) as timeout:\n    # Slow code\nif timeout.triggered:\n    # Handle timeout\n```\nWith an exception:\n```python\nfrom datetime import timedelta\nfrom overdue import timeout_set_to, TaskAbortedError\n\ntry:\n    with timeout_set_to(timedelta(milliseconds=250), raise_exception=True):\n        # Slow code\nexcept TaskAbortedError:\n    # Handle timeout\n```\n\n## Using a decorator\nWith an exception:\n```python\nfrom overdue import timecapped_to, TaskAbortedError\n\n@timecapped_to(0.25)\ndef my_slow_function() -> None:\n    # Slow code\n\ntry:\n    my_slow_function()\nexcept TaskAbortedError:\n    # Handle timeout\n```\n\nWithout exceptions:\n```python\nfrom overdue import in_time_or_none\n\n@in_time_or_none(0.25)\ndef my_slow_function() -> int:\n    # Slow code\n    return 7\n\nif (result := my_slow_function()) is None:\n    # Handle timeout\n```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Easy timeout actions for any Python code with contextmanagers or decorators",
    "version": "0.1.5",
    "project_urls": {
        "source": "https://github.com/kajaste/overdue"
    },
    "split_keywords": [
        "error-handling",
        " exception",
        " performance",
        " scalability",
        " timeout"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "53012a14f0d4e9777452f444fbb96dabc8abedf482ae140a1e22a05baab05813",
                "md5": "fbde01ab30b8c99cd0ad7af9de391781",
                "sha256": "3ece13e9f7ef8636b9c906143b9573a333ef81953e38d870b4e0732c0d7ce063"
            },
            "downloads": -1,
            "filename": "overdue-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fbde01ab30b8c99cd0ad7af9de391781",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 3523,
            "upload_time": "2024-12-17T19:20:16",
            "upload_time_iso_8601": "2024-12-17T19:20:16.977407Z",
            "url": "https://files.pythonhosted.org/packages/53/01/2a14f0d4e9777452f444fbb96dabc8abedf482ae140a1e22a05baab05813/overdue-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0f287a099f4f699c23b0b7701a9901325b4fd1c3812bb45be9438f97a16d25ed",
                "md5": "f1d4822bbb2722b89f531ab76e4344a2",
                "sha256": "6781da739f802d904f4a0d404824f315c5cb1911b309f7a6d4b5f465374cd2da"
            },
            "downloads": -1,
            "filename": "overdue-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f1d4822bbb2722b89f531ab76e4344a2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 13240,
            "upload_time": "2024-12-17T19:20:19",
            "upload_time_iso_8601": "2024-12-17T19:20:19.272846Z",
            "url": "https://files.pythonhosted.org/packages/0f/28/7a099f4f699c23b0b7701a9901325b4fd1c3812bb45be9438f97a16d25ed/overdue-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 19:20:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kajaste",
    "github_project": "overdue",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "overdue"
}
        
Elapsed time: 0.40795s