python/dna/apy/worker.py
def setup(title, output='json', timezone=None):
    ''' Implement celery workers using json and redis '''
    timezone = timezone or dna.time_utils._detect_timezone()

    broker_url = 'redis://{}:{}/{}'.format(
        os.environ.get('BROKER_HOST', 'localhost'),
        os.environ.get('BROKER_PORT', 6379),
        0
    )

    app = Celery(title, broker=broker_url)

    app.conf.update(
        CELERY_TASK_SERIALIZER=output,
        CELERY_ACCEPT_CONTENT=[output],  # Ignore other content
        CELERY_RESULT_SERIALIZER=output,
        CELERY_RESULT_BACKEND=broker_url,
        CELERY_TIMEZONE=timezone,
        CELERYD_FORCE_EXECV=True,
        CELERY_ENABLE_UTC=True,
        CELERY_IGNORE_RESULT=False
    )

    return app
def setup(title, output='json', timezone=None):
    ''' Implement celery workers using json and redis '''
    timezone = timezone or dna.time_utils._detect_timezone()

    broker_url = 'redis://{}:{}/{}'.format(
        os.environ.get('BROKER_HOST', 'localhost'),
        os.environ.get('BROKER_PORT', 6379),
        0
    )

    app = Celery(title, broker=broker_url)

    app.conf.update(
        CELERY_TASK_SERIALIZER=output,
        CELERY_ACCEPT_CONTENT=[output],  # Ignore other content
        CELERY_RESULT_SERIALIZER=output,
        CELERY_RESULT_BACKEND=broker_url,
        CELERY_TIMEZONE=timezone,
        CELERYD_FORCE_EXECV=True,
        CELERY_ENABLE_UTC=True,
        CELERY_IGNORE_RESULT=False
    )

    return app
Implement celery workers using json and redis