dramatiq-crontab


Namedramatiq-crontab JSON
Version 1.0.6 PyPI version JSON
download
home_page
SummaryCron style scheduler for asynchronous Dramatiq tasks in Django.
upload_time2024-02-26 12:20:57
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords django dramatiq tasks scheduler
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dramatiq Crontab

![dramtiq-crontab logo: person in front of a schedule](https://raw.githubusercontent.com/voiio/dramatiq-crontab/main/dramatiq-crontab.png)

**Cron style scheduler for asynchronous Dramatiq tasks in Django.**

* setup recurring tasks via crontab syntax
* lightweight helpers build on robust tools like [Dramatiq][dramatiq] and [APScheduler][apscheduler]
* [Sentry][sentry] cron monitor support

[![PyPi Version](https://img.shields.io/pypi/v/dramatiq-crontab.svg)](https://pypi.python.org/pypi/dramatiq-crontab/)
[![Test Coverage](https://codecov.io/gh/voiio/dramatiq-crontab/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/dramatiq-crontab)
[![GitHub License](https://img.shields.io/github/license/voiio/dramatiq-crontab)](https://raw.githubusercontent.com/voiio/dramatiq-crontab/master/LICENSE)

## Setup

You need to have [Dramatiq][dramatiq] installed and setup properly.

```ShellSession
python3 -m pip install dramatiq-crontab
# or
python3 -m pip install dramatiq-crontab[sentry]  # with sentry cron monitor support
```

Add `dramatiq_crontab` to your `INSTALLED_APPS` in `settings.py`:

```python
# settings.py
INSTALLED_APPS = [
    'dramatiq_crontab',
    # ...
]
```

Finally, you lauch the scheduler in a separate process:

```ShellSession
python3 manage.py crontab
```

### Setup Redis as a lock backend (optional)

If you use Redis as a broker, you can use Redis as a lock backend as well.
The lock backend is used to prevent multiple instances of the scheduler
from running at the same time. This is important if you have multiple
instances of your application running.

```python
# settings.py
DRAMATIQ_CRONTAB = {
    "REDIS_URL": "redis://localhost:6379/0",
}
```

## Usage

```python
# tasks.py
import dramatiq
from dramatiq_crontab import cron


@cron("*/5 * * * *")  # every 5 minutes
@dramatiq.actor
def my_task():
    my_task.logger.info("Hello World")
```

### Sentry Cron Monitors

If you use [Sentry][sentry] you can add cron monitors to your tasks.
The monitor's slug will be the actor's name. Like `my_task` in the example above.


### The crontab command

```ShellSession
$ python3 manage.py crontab --help
usage: manage.py crontab [-h] [--no-task-loading] [--no-heartbeat] [--version] [-v {0,1,2,3}]
                         [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                         [--force-color] [--skip-checks]

Run dramatiq task scheduler for all tasks with the `cron` decorator.

options:
  -h, --help            show this help message and exit
  --no-task-loading     Don't load tasks from installed apps.
  --no-heartbeat        Don't start the heartbeat actor.
```

[dramatiq]: https://dramatiq.io/
[apscheduler]: https://apscheduler.readthedocs.io/en/stable/
[sentry]: https://docs.sentry.io/product/crons/


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dramatiq-crontab",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "Django,Dramatiq,tasks,scheduler",
    "author": "",
    "author_email": "Rust Saiargaliev <fly.amureki@gmail.com>, Johannes Maron <johannes@maron.family>, Mostafa Mohamed <mostafa.anm91@gmail.com>, Jacqueline Kraus <jacquelinekraus1992@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/9f/71/b82ad4ca89f6e74d4c9e6c09a142e00bdb2e289b8e320af0bd439703afaf/dramatiq_crontab-1.0.6.tar.gz",
    "platform": null,
    "description": "# Dramatiq Crontab\n\n![dramtiq-crontab logo: person in front of a schedule](https://raw.githubusercontent.com/voiio/dramatiq-crontab/main/dramatiq-crontab.png)\n\n**Cron style scheduler for asynchronous Dramatiq tasks in Django.**\n\n* setup recurring tasks via crontab syntax\n* lightweight helpers build on robust tools like [Dramatiq][dramatiq] and [APScheduler][apscheduler]\n* [Sentry][sentry] cron monitor support\n\n[![PyPi Version](https://img.shields.io/pypi/v/dramatiq-crontab.svg)](https://pypi.python.org/pypi/dramatiq-crontab/)\n[![Test Coverage](https://codecov.io/gh/voiio/dramatiq-crontab/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/dramatiq-crontab)\n[![GitHub License](https://img.shields.io/github/license/voiio/dramatiq-crontab)](https://raw.githubusercontent.com/voiio/dramatiq-crontab/master/LICENSE)\n\n## Setup\n\nYou need to have [Dramatiq][dramatiq] installed and setup properly.\n\n```ShellSession\npython3 -m pip install dramatiq-crontab\n# or\npython3 -m pip install dramatiq-crontab[sentry]  # with sentry cron monitor support\n```\n\nAdd `dramatiq_crontab` to your `INSTALLED_APPS` in `settings.py`:\n\n```python\n# settings.py\nINSTALLED_APPS = [\n    'dramatiq_crontab',\n    # ...\n]\n```\n\nFinally, you lauch the scheduler in a separate process:\n\n```ShellSession\npython3 manage.py crontab\n```\n\n### Setup Redis as a lock backend (optional)\n\nIf you use Redis as a broker, you can use Redis as a lock backend as well.\nThe lock backend is used to prevent multiple instances of the scheduler\nfrom running at the same time. This is important if you have multiple\ninstances of your application running.\n\n```python\n# settings.py\nDRAMATIQ_CRONTAB = {\n    \"REDIS_URL\": \"redis://localhost:6379/0\",\n}\n```\n\n## Usage\n\n```python\n# tasks.py\nimport dramatiq\nfrom dramatiq_crontab import cron\n\n\n@cron(\"*/5 * * * *\")  # every 5 minutes\n@dramatiq.actor\ndef my_task():\n    my_task.logger.info(\"Hello World\")\n```\n\n### Sentry Cron Monitors\n\nIf you use [Sentry][sentry] you can add cron monitors to your tasks.\nThe monitor's slug will be the actor's name. Like `my_task` in the example above.\n\n\n### The crontab command\n\n```ShellSession\n$ python3 manage.py crontab --help\nusage: manage.py crontab [-h] [--no-task-loading] [--no-heartbeat] [--version] [-v {0,1,2,3}]\n                         [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]\n                         [--force-color] [--skip-checks]\n\nRun dramatiq task scheduler for all tasks with the `cron` decorator.\n\noptions:\n  -h, --help            show this help message and exit\n  --no-task-loading     Don't load tasks from installed apps.\n  --no-heartbeat        Don't start the heartbeat actor.\n```\n\n[dramatiq]: https://dramatiq.io/\n[apscheduler]: https://apscheduler.readthedocs.io/en/stable/\n[sentry]: https://docs.sentry.io/product/crons/\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Cron style scheduler for asynchronous Dramatiq tasks in Django.",
    "version": "1.0.6",
    "project_urls": {
        "Changelog": "https://github.com/voiio/dramatiq-crontab/releases",
        "Project-URL": "https://github.com/voiio/dramatiq-crontab"
    },
    "split_keywords": [
        "django",
        "dramatiq",
        "tasks",
        "scheduler"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "994df176e560210dd14cecf80a23376ae017ac7a7f3b9825f18008c685762d8f",
                "md5": "c25567e72f57f30f15a6b7a88cbcf379",
                "sha256": "c68d050cb264d57ff8cd08dd28e7f6a667b170c7165836886264e2ba56cce128"
            },
            "downloads": -1,
            "filename": "dramatiq_crontab-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c25567e72f57f30f15a6b7a88cbcf379",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8124,
            "upload_time": "2024-02-26T12:20:55",
            "upload_time_iso_8601": "2024-02-26T12:20:55.454644Z",
            "url": "https://files.pythonhosted.org/packages/99/4d/f176e560210dd14cecf80a23376ae017ac7a7f3b9825f18008c685762d8f/dramatiq_crontab-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f71b82ad4ca89f6e74d4c9e6c09a142e00bdb2e289b8e320af0bd439703afaf",
                "md5": "22f182517cdd0c0653051574095cfb85",
                "sha256": "6db7d848aad9bebf2c98cec5418756d2dfe4fd3406bd95ea0c9a5541c825413e"
            },
            "downloads": -1,
            "filename": "dramatiq_crontab-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "22f182517cdd0c0653051574095cfb85",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6454,
            "upload_time": "2024-02-26T12:20:57",
            "upload_time_iso_8601": "2024-02-26T12:20:57.212463Z",
            "url": "https://files.pythonhosted.org/packages/9f/71/b82ad4ca89f6e74d4c9e6c09a142e00bdb2e289b8e320af0bd439703afaf/dramatiq_crontab-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 12:20:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "voiio",
    "github_project": "dramatiq-crontab",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dramatiq-crontab"
}
        
Elapsed time: 0.20099s