{"id":50277884,"url":"https://github.com/imsweb/django-dbtasks","last_synced_at":"2026-05-27T22:02:18.632Z","repository":{"id":329848029,"uuid":"1120250055","full_name":"imsweb/django-dbtasks","owner":"imsweb","description":"Database task backend and runner for Django tasks","archived":false,"fork":false,"pushed_at":"2025-12-31T03:34:17.000Z","size":92,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-02T01:47:28.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imsweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-20T19:55:13.000Z","updated_at":"2025-12-31T03:34:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/imsweb/django-dbtasks","commit_stats":null,"previous_names":["imsweb/django-dbtasks"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imsweb/django-dbtasks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imsweb%2Fdjango-dbtasks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imsweb%2Fdjango-dbtasks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imsweb%2Fdjango-dbtasks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imsweb%2Fdjango-dbtasks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imsweb","download_url":"https://codeload.github.com/imsweb/django-dbtasks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imsweb%2Fdjango-dbtasks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33585203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-27T22:02:15.516Z","updated_at":"2026-05-27T22:02:18.610Z","avatar_url":"https://github.com/imsweb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-dbtasks\n\nDatabase backend and runner for [Django tasks](https://docs.djangoproject.com/en/dev/topics/tasks/) (new in 6.0).\n\n`django-dbtasks` is tested on PostgreSQL, SQLite, and MySQL for versions of Python back to 3.12, including the free-threading builds.\n\n_Note when using SQLite it is recommended to set `OPTIONS[\"transaction_mode\"] = \"IMMEDIATE\"` - see https://forum.djangoproject.com/t/sqlite-and-database-is-locked-error/26994 for more information._\n\n\n## Quickstart\n\nInstall the `django-dbtasks` package from PyPI, and configure your [TASKS setting](https://docs.djangoproject.com/en/dev/ref/settings/#std-setting-TASKS) as follows:\n\n```python\nTASKS = {\n    \"default\": {\n        \"BACKEND\": \"dbtasks.backend.DatabaseBackend\",\n        \"OPTIONS\": {\n            # Set this to True to execute tasks immediately (no need for a runner).\n            \"immediate\": False,\n            # Whether to send `task_enqueued`, `task_started`, and `task_finished`.\n            \"signals\": True,\n            # How long to retain ScheduledTasks in the database. Forever if not set.\n            \"retain\": datetime.timedelta(days=7),\n            # Tasks to run periodically.\n            \"periodic\": {\n                # Runs at 3:30am every Monday through Friday.\n                \"myproject.tasks.maintenance\": \"30 3 * * 1-5\",\n            },\n        },\n    },\n}\n```\n\n## Runner\n\n`django-dbtasks` includes a dedicated `taskrunner` management command:\n\n```\nusage: manage.py taskrunner [-h] [-w WORKERS] [-i WORKER_ID] [--backend BACKEND]\n                            [--delay DELAY] [--no-periodic]\n```\n\nIt is also straightforward to run the runner in a thread of its own:\n\n```python\nrunner = Runner(workers=4, worker_id=\"in-process\")\nt = threading.Thread(target=runner.run)\nt.start()\n...\nrunner.stop()\nt.join()\n```\n\n`django-dbtasks` itself is tested on free-threading builds of Python 3.13 and 3.14, but compatibility will depend on your database driver and other packages.\n\n\n## Periodic Tasks\n\nAs shown in the [quickstart](#quickstart), periodic tasks are specified as a mapping in the backend `OPTIONS` under the `periodic` key. The keys of the mapping should be dotted paths to the tasks, and the values should either be a string in [crontab format](https://crontab.guru), or an instance of `dbtasks.Periodic`. Using a `dbtasks.Periodic` allows you to specify `args` and `kwargs` (as values or callables) that will be passed to the task, along with a custom `retain` duration.\n\n\n## Logging\n\nBe sure to add a `dbtasks` logger to your `LOGGING` setting:\n\n```python\nLOGGING = {\n    ...\n    \"loggers\": {\n        \"dbtasks\": {\n            \"handlers\": [\"console\"],\n            \"level\": \"INFO\",\n        },\n    },\n}\n```\n\n## Testing\n\nThere is a `RunnerTestCase` that starts a runner for the duration of a test suite. See [test_tasks.py](tests/tests/test_tasks.py) for example usage.\n\n\n## Extras\n\n`django-dbtasks` comes with a number of optional features for integration into various environments.\n\n\n### `dbtasks.contrib.serve`\n\nThis is a Django app you can add to `INSTALLED_APPS` to enable a `serve` management command that runs your site in a [Granian](https://github.com/emmett-framework/granian) server, with options to also start an integrated task runner. For instance, the following command will serve your site on `127.0.0.1:8000`, start a runner, and reload your server (and tasks!) on code changes:\n\n```\nmanage.py serve -k -r\n```\n\nRunning an integrated task runner (with `-k/--tasks`) is not a great idea in production, but is excellent for development. Granian is a production-caliber server, so you can also use `serve` in production alongside a separate [taskrunner command](#runner).\n\nYou can install the `django-dbtasks[serve]` extra to include Granian automatically.\n\n\n### uWSGI mule\n\nYou can run a [uWSGI mule](https://uwsgi-docs.readthedocs.io/en/latest/Mules.html) that starts a task runner by passing `--mule=dbtasks.contrib.mule:taskrunner` or specifying `\u003cmule\u003edbtasks.contrib.mule:taskrunner\u003c/mule\u003e` in your XML config.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimsweb%2Fdjango-dbtasks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimsweb%2Fdjango-dbtasks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimsweb%2Fdjango-dbtasks/lists"}