{"id":21189303,"url":"https://github.com/uptick/django-dramatiq-pg","last_synced_at":"2025-07-10T02:31:40.287Z","repository":{"id":57419809,"uuid":"244246983","full_name":"uptick/django-dramatiq-pg","owner":"uptick","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-04T22:01:39.000Z","size":44,"stargazers_count":22,"open_issues_count":4,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-27T00:42:16.185Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uptick.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-02T00:32:06.000Z","updated_at":"2023-08-28T17:55:09.000Z","dependencies_parsed_at":"2023-02-04T06:25:16.343Z","dependency_job_id":null,"html_url":"https://github.com/uptick/django-dramatiq-pg","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fdjango-dramatiq-pg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fdjango-dramatiq-pg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fdjango-dramatiq-pg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fdjango-dramatiq-pg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uptick","download_url":"https://codeload.github.com/uptick/django-dramatiq-pg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225615295,"owners_count":17496941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-20T18:51:41.353Z","updated_at":"2024-11-20T18:51:41.862Z","avatar_url":"https://github.com/uptick.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==================\ndjango_dramatiq_pg\n==================\n\n.. image:: https://badge.fury.io/py/django-dramatiq-pg.svg\n    :target: https://pypi.org/project/django-dramatiq-pg\n\n.. image:: https://img.shields.io/pypi/pyversions/django-dramatiq-pg.svg\n    :target: https://pypi.org/project/django-dramatiq-pg\n\ndramatiq-pg_ integration for django_.\n\n    .. _dramatiq-pg: https://pypi.org/project/dramatiq-pg/\n    .. _django: https://pypi.org/project/Django/\n\nInstallation\n------------\n\n1. Install with pip\n\n   .. code-block:: sh\n\n    $ pip install django-dramatiq-pg\n\n2. Add to your ``INSTALLED_APPS`` list in settings.py\n\n   .. code-block:: python\n\n    INSTALLED_APPS = [\n        ...\n        'django_dramatiq_pg',\n    ]\n\n3. Create a Registry, and register your tasks\n\n   .. code-block:: python\n\n     from django_dramatiq_pg.registry import Registry\n\n     tasks = Registry()\n\n\n     @tasks.actor\n     def mytask():\n         ...\n\n4. Configure\n\n   .. code-block:: python\n\n    DRAMATIQ_BROKER = {\n        \"OPTIONS\": {\n            \"url\": \"postgres:///mydb\",\n        },\n        \"MIDDLEWARE\": [\n            \"dramatiq.middleware.TimeLimit\",\n            \"dramatiq.middleware.Callbacks\",\n            \"dramatiq.middleware.Retries\",\n        ],\n    }\n    DRAMATIQ_REGISTRY = 'myapp.registry.tasks'\n\n5. Start the worker process:\n\n   .. code-block:: sh\n\n    $ dramatiq django_dramatiq_pg.worker\n\nThis worker module will auto-discover any module called 'actors' in\n``INSTALLED_APPS``.\n\nRegistry\n========\n\nIn a typical `dramatiq` application, the `Broker` is configured before any\ntasks are registered. However, as `Django` is in control of the intialisation\nsequence, there is an issue of ordering; the `actor` decorator assumes the\nbroker is already configured.\n\nTo resolve this, `django_dramatiq_pg` provides a `Registry` for your tasks,\nwhich is then bound to the `Broker` when Django initialises.\n\nIn your code, declare a `Registry` instance, and use its `.actor` method to\ndecorate your task functions. Then tell `django_dramatiq_pg` to use your\nregistry with the `DRAMATIQ_REGISTRY` setting.\n\nIf you do not specify one, `django_dramatiq_pg` will create one on start.\n\nThe registry can be accessed as the `.registry` attribute on the\n`django_dramatiq_pg` App instance.\n\nSettings\n--------\n\nDRAMATIQ_BROKER\n  A dict of options to pass when instantiating the broker.\n\nDRAMATIC_BROKER['OPTIONS']\n  Arguments to pass to the Broker.\n\nDRAMATIC_BROKER['MIDDLEWARE']\n  A list of middleware classes to be passed to the broker.\n\n  These can either be import strings, or instances.\n\nDRAMATIQ_ENCODER\n  Default: None\n\n  Import path for encoder class.\n\nDRAMATIQ_ACTORS_MODULE\n  Default: 'actors'\n\n  Name of module use to auto-discover actors in INSTALLED_APPS.\n\nDRAMATIQ_REGISTRY\n\n  Import path for the task Registry instance.\n\n  This should refer to an instance of `django_dramatiq_pg.registry.Registry`.\n\n  This resolves the chicken/egg problem of declaring tasks before the broker is\n  configured.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptick%2Fdjango-dramatiq-pg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuptick%2Fdjango-dramatiq-pg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptick%2Fdjango-dramatiq-pg/lists"}