autocron


Nameautocron JSON
Version 0.9.5 PyPI version JSON
download
home_pagehttps://github.com/kbr/autocron
SummaryAsynchronous background tasks for Python web-frameworks with no dependencies
upload_time2024-04-15 13:41:23
maintainerNone
docs_urlNone
authorKlaus Bremer
requires_pythonNone
licenseMIT
keywords tasks background python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # autocron

![](https://img.shields.io/pypi/pyversions/autocron.svg)
![](https://img.shields.io/pypi/l/autocron.svg)


**autocron** is a Python background task library with no dependencies beside the standard library. It works out of the box with webframeworks like django, pyramid, flask, bottle, tornado or starlette.

**autocron** makes it easy to delegate long running and recurring tasks to external processes. No hassle with configuration-files.

**autocron** is designed for the vast majority of webapplications that don't need massive scaling. And don't want to add unnecessary dependencies.


## Installation

For installation use pip:

```
    $ pip install autocron
```

## Quickstart

autocron provides two decorators: ``cron`` that takes a string in [cron](https://en.wikipedia.org/wiki/Cron#CRON_expression)-format as argument, but accepts also keyword-arguments like *minutes* and *hours*. And ``delay`` to delegate a long running task to a background process.

Here is a simple example how to use autocron with the flask web-framework that can be run with ``$ flak --app application run``:

```
    # application.py

    import autocron
    from flask import Flask

    app = Flask(__name__)
    autocron.start("the_flask_app.db")

    @autocron.cron("* * * * *")
    def cronjob():
        # do something from time to time ...

    @autocron.delay
    def do_this_later():
        # time consuming task here ...

    @app.route("/later")
    def later():
        do_this_later()
        return "delayed action triggered"
```

After creating the flask ``app`` instance calling ``autocron.start(<databasename>)`` starts the background workers. The ``cron`` decorated ``cronjob()`` function will get executed every minute and the ``delay`` decorated ``do_this_later()`` function gets delegated to the background worker every time the application processes the ``/later`` url. Terminating the application will shut down the worker processes.

More information and examples how to use autocron with other frameworks are at the documentation.


## Documentation

The full documentation and release notes are at [https://autocron.readthedocs.org](https://autocron.readthedocs.org)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kbr/autocron",
    "name": "autocron",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "tasks, background, python",
    "author": "Klaus Bremer",
    "author_email": "bremer@bremer-media.com",
    "download_url": "https://files.pythonhosted.org/packages/93/2a/b88a5f2f7f8773a8e631731425e2058b78fce571893bd449cd6762b85a2b/autocron-0.9.5.tar.gz",
    "platform": "any",
    "description": "# autocron\n\n![](https://img.shields.io/pypi/pyversions/autocron.svg)\n![](https://img.shields.io/pypi/l/autocron.svg)\n\n\n**autocron** is a Python background task library with no dependencies beside the standard library. It works out of the box with webframeworks like django, pyramid, flask, bottle, tornado or starlette.\n\n**autocron** makes it easy to delegate long running and recurring tasks to external processes. No hassle with configuration-files.\n\n**autocron** is designed for the vast majority of webapplications that don't need massive scaling. And don't want to add unnecessary dependencies.\n\n\n## Installation\n\nFor installation use pip:\n\n```\n    $ pip install autocron\n```\n\n## Quickstart\n\nautocron provides two decorators: ``cron`` that takes a string in [cron](https://en.wikipedia.org/wiki/Cron#CRON_expression)-format as argument, but accepts also keyword-arguments like *minutes* and *hours*. And ``delay`` to delegate a long running task to a background process.\n\nHere is a simple example how to use autocron with the flask web-framework that can be run with ``$ flak --app application run``:\n\n```\n    # application.py\n\n    import autocron\n    from flask import Flask\n\n    app = Flask(__name__)\n    autocron.start(\"the_flask_app.db\")\n\n    @autocron.cron(\"* * * * *\")\n    def cronjob():\n        # do something from time to time ...\n\n    @autocron.delay\n    def do_this_later():\n        # time consuming task here ...\n\n    @app.route(\"/later\")\n    def later():\n        do_this_later()\n        return \"delayed action triggered\"\n```\n\nAfter creating the flask ``app`` instance calling ``autocron.start(<databasename>)`` starts the background workers. The ``cron`` decorated ``cronjob()`` function will get executed every minute and the ``delay`` decorated ``do_this_later()`` function gets delegated to the background worker every time the application processes the ``/later`` url. Terminating the application will shut down the worker processes.\n\nMore information and examples how to use autocron with other frameworks are at the documentation.\n\n\n## Documentation\n\nThe full documentation and release notes are at [https://autocron.readthedocs.org](https://autocron.readthedocs.org)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Asynchronous background tasks for Python web-frameworks with no dependencies",
    "version": "0.9.5",
    "project_urls": {
        "Code": "https://github.com/kbr/autocron",
        "Homepage": "https://github.com/kbr/autocron",
        "Issue tracker": "https://github.com/kbr/autocron/issues"
    },
    "split_keywords": [
        "tasks",
        " background",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ffc9b827115d219fcf03288d739d71639b242993dad694e83810600d4563cbaa",
                "md5": "6aa6d73b1faa9c441d01867a263699dd",
                "sha256": "e8e17962e8936cf158673fe6a774f13484c6081cb05db5d5d2496f6fc470976f"
            },
            "downloads": -1,
            "filename": "autocron-0.9.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6aa6d73b1faa9c441d01867a263699dd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 33368,
            "upload_time": "2024-04-15T13:41:22",
            "upload_time_iso_8601": "2024-04-15T13:41:22.453217Z",
            "url": "https://files.pythonhosted.org/packages/ff/c9/b827115d219fcf03288d739d71639b242993dad694e83810600d4563cbaa/autocron-0.9.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "932ab88a5f2f7f8773a8e631731425e2058b78fce571893bd449cd6762b85a2b",
                "md5": "13d3c7a9cee56a52d4c3e42881e046bb",
                "sha256": "c07dfc305279e51041c69625a5e37a35ae996d0e0513fa825d4b09215fe4cee0"
            },
            "downloads": -1,
            "filename": "autocron-0.9.5.tar.gz",
            "has_sig": false,
            "md5_digest": "13d3c7a9cee56a52d4c3e42881e046bb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29588,
            "upload_time": "2024-04-15T13:41:23",
            "upload_time_iso_8601": "2024-04-15T13:41:23.650313Z",
            "url": "https://files.pythonhosted.org/packages/93/2a/b88a5f2f7f8773a8e631731425e2058b78fce571893bd449cd6762b85a2b/autocron-0.9.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 13:41:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kbr",
    "github_project": "autocron",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "autocron"
}
        
Elapsed time: 0.25131s