dramatiq-crontab


Namedramatiq-crontab JSON
Version 1.0.8 PyPI version JSON
download
home_pageNone
SummaryCron style scheduler for asynchronous Dramatiq tasks in Django.
upload_time2024-11-27 15:36:18
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
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": null,
    "name": "dramatiq-crontab",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "Django, Dramatiq, tasks, scheduler",
    "author": null,
    "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/03/6d/b944fce3d144110e08d376dbe06a5362d307a2cae6ea0638cf6116e6fba4/dramatiq_crontab-1.0.8.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": null,
    "summary": "Cron style scheduler for asynchronous Dramatiq tasks in Django.",
    "version": "1.0.8",
    "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": "0bc5fff41038fd7f9e1ec118e7efe3ad6d666492f5462dc4472a1bf7d1c73944",
                "md5": "f4192297739c509948236f6108635b38",
                "sha256": "caa5e88f1dcb84ffddcf0754fbdcd59a1a155b91357231a063625a1464c7e810"
            },
            "downloads": -1,
            "filename": "dramatiq_crontab-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4192297739c509948236f6108635b38",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8230,
            "upload_time": "2024-11-27T15:36:16",
            "upload_time_iso_8601": "2024-11-27T15:36:16.263002Z",
            "url": "https://files.pythonhosted.org/packages/0b/c5/fff41038fd7f9e1ec118e7efe3ad6d666492f5462dc4472a1bf7d1c73944/dramatiq_crontab-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "036db944fce3d144110e08d376dbe06a5362d307a2cae6ea0638cf6116e6fba4",
                "md5": "c1879c83655d15afe3687fbe764ab52e",
                "sha256": "51bf3ef7d82ca1d4141ec0c617ceaa3bf2c2ae0eb57ec96eeff015495b102a90"
            },
            "downloads": -1,
            "filename": "dramatiq_crontab-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "c1879c83655d15afe3687fbe764ab52e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6670,
            "upload_time": "2024-11-27T15:36:18",
            "upload_time_iso_8601": "2024-11-27T15:36:18.135803Z",
            "url": "https://files.pythonhosted.org/packages/03/6d/b944fce3d144110e08d376dbe06a5362d307a2cae6ea0638cf6116e6fba4/dramatiq_crontab-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-27 15:36:18",
    "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.38931s