# 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
```
or conda:
```
$ conda 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 ``$ flask --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/46/33/0fb9e5d30a8029fd95d859b756a5bb62a7e449227a584b4434b8c440d3a7/autocron-1.2.2.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\nor conda:\n\n```\n $ conda 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 ``$ flask --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": "1.2.2",
"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": "00f43f64bc85f3c6dd3708cde19684d5863c99931aa1ce08638ff62b573dc38d",
"md5": "25d57673dff5d31d717c5f133e4cba16",
"sha256": "aa36f8ea2d7c9bebe618a773f2ee16bd8ad99f0230883faef693a336f241dbb8"
},
"downloads": -1,
"filename": "autocron-1.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "25d57673dff5d31d717c5f133e4cba16",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 37247,
"upload_time": "2024-10-20T14:29:15",
"upload_time_iso_8601": "2024-10-20T14:29:15.470587Z",
"url": "https://files.pythonhosted.org/packages/00/f4/3f64bc85f3c6dd3708cde19684d5863c99931aa1ce08638ff62b573dc38d/autocron-1.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "46330fb9e5d30a8029fd95d859b756a5bb62a7e449227a584b4434b8c440d3a7",
"md5": "a61deddf5a5942a472e186480aa1f424",
"sha256": "fea938a38798df625577b1c3232fd7e99b10fc1e913d47872d77d0b5d3ddf00c"
},
"downloads": -1,
"filename": "autocron-1.2.2.tar.gz",
"has_sig": false,
"md5_digest": "a61deddf5a5942a472e186480aa1f424",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 33197,
"upload_time": "2024-10-20T14:29:16",
"upload_time_iso_8601": "2024-10-20T14:29:16.587824Z",
"url": "https://files.pythonhosted.org/packages/46/33/0fb9e5d30a8029fd95d859b756a5bb62a7e449227a584b4434b8c440d3a7/autocron-1.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-20 14:29:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kbr",
"github_project": "autocron",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "autocron"
}