0

我在跑步:

  • 视窗 10
  • 姜戈 4+
  • Python 3.9.x
  • 最新版本的戏剧
  • 最新版本的 Dramatiq_abort
  • 最新版本的 django_dramatiq

设置.py

###
### For dramatiq tasks!
###
import urllib.parse
import dramatiq
import dramatiq_abort

REDIS_USER = "myuser"
REDIS_PASS = "mypassword"
REDIS_URL = "redis://%s:%s@localhost:6379/0" % (urllib.parse.quote(REDIS_USER, safe=''), urllib.parse.quote(REDIS_PASS, safe=''))

# Frontend

DRAMATIQ_BROKER = {
    "BROKER": "dramatiq.brokers.redis.RedisBroker",
    "OPTIONS": {
        "url": REDIS_URL,
    },
    "MIDDLEWARE": [
        "dramatiq.middleware.Prometheus",
        "dramatiq.middleware.AgeLimit",
        "dramatiq.middleware.TimeLimit",
        "dramatiq.middleware.Callbacks",
        "dramatiq.middleware.Retries",
        "dramatiq_abort.middleware.Abort", #I import Abort
        "dramatiq_abort.middleware.Abortable", # I import Abortable
        "django_dramatiq.middleware.DbConnectionsMiddleware",
        "django_dramatiq.middleware.AdminMiddleware",
    ],
    # When I put this here, I get the error __init__() missing 1 required keyword-only argument: 'backend'
    #"BACKEND": "dramatiq_abort.backends.RedisBackend(client=None).from_url(" + REDIS_URL + ")"
}

# Defines which database should be used to persist Task objects when the
# AdminMiddleware is enabled.  The default value is "default".
DRAMATIQ_TASKS_DATABASE = "default"

# Backend

DRAMATIQ_RESULT_BACKEND = {
    "BACKEND": "dramatiq.results.backends.redis.RedisBackend",
    "BACKEND_OPTIONS": {
        "url": REDIS_URL,
    },
    "MIDDLEWARE_OPTIONS": {
        "result_ttl": 60000
    },
    #"BACKEND": "dramatiq_abort.backends.RedisBackend(" + REDIS_URL + ")",
    # When I put it here, I get No module named 'dramatiq_abort.backends.RedisBackend(client=None)
    "BACKEND": "dramatiq_abort.backends.RedisBackend(client=None).from_url(" + REDIS_URL + ")"
}


###
### End of dramatiq tasks!
###

我正确配置了 django_dramatiq,因此正确配置了 Dramatiq。

问题是如何配置 Dramatiq_abort 和 django_dramatiq?

4

0 回答 0