Beispiel #1
0
 def __init__(self, sub_manager, config):
     rabbitmq_host = config.get("RABBITMQ_HOST", None)
     if rabbitmq_host is not None:
         middleware = [
             AgeLimit(), TimeLimit(), ShutdownNotifications(),
             Callbacks(), Pipelines(), Retries()
         ]
         self.broker = RabbitmqBroker(
             host=rabbitmq_host, middleware=middleware)
     else:
         self.broker = get_broker()
Beispiel #2
0
def broker():
    broker = SQSBroker(
        namespace="dramatiq_sqs_tests",
        middleware=[
            AgeLimit(),
            TimeLimit(),
            Callbacks(),
            Pipelines(),
            Retries(min_backoff=1000, max_backoff=900000, max_retries=96),
        ],
    )
    dramatiq.set_broker(broker)
    yield broker
    for queue in broker.queues.values():
        queue.delete()
Beispiel #3
0
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": "db.sqlite3",
    }
}

# Queue
# =====
DRAMATIQ_BROKER = {
    "BROKER":
    "dramatiq.brokers.stub.StubBroker",
    "OPTIONS": {},
    "MIDDLEWARE": [
        "dramatiq.middleware.AgeLimit",
        TimeLimit(time_limit=36000000),
        "dramatiq.middleware.Retries",
        "django_dramatiq.middleware.AdminMiddleware",
        "django_dramatiq.middleware.DbConnectionsMiddleware",
    ]
}

# Auth
# ====
AUTH_PASSWORD_VALIDATORS = [
    {
        "NAME":
        "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
    },
    {
        "NAME":
Beispiel #4
0
from transcript_hero.business.subscriptions import SubscriptionService, SubscriptionManager
from transcript_hero.business.users import UserService
from transcript_hero_job.tasks import expire_subscriptions, renew_subscription

config = parse_config(os.environ["TRANSCRIPT_HERO_SETTINGS"])
db = Database(config["SQLALCHEMY_DATABASE_URI"], scoped_session=scoped_session)

subscription_service = SubscriptionService(db, config)
user_service = UserService(db, config)
sub_manager = SubscriptionManager(user_service, subscription_service)

rabbitmq_host = config.get("RABBITMQ_HOST", None)
if rabbitmq_host is not None:
    middleware = [
        AgeLimit(),
        TimeLimit(),
        ShutdownNotifications(),
        Callbacks(),
        Pipelines(),
        Retries()
    ]
    broker = dramatiq.brokers.rabbitmq.RabbitmqBroker(host=rabbitmq_host,
                                                      middleware=middleware)
    dramatiq.set_broker(broker)
    tries = 1
    while True:
        try:
            # throws an exception if we are not connected
            # to RabbitMQ
            broker.connection
            break  # if we reach here we are connected and should stop waiting