#!/usr/bin/env python3


# import ssl

print("Loading courseware execution runner custom configuration for Celery!")

BROKER_URL = 'amqp://hoou:hohohoho@abu1:5672//'
#BROKER_USE_SSL = {
#  'keyfile': '/var/ssl/private/worker-key.pem',
#  'certfile': '/var/ssl/amqp-server-cert.pem',
#  'ca_certs': '/var/ssl/myca.pem',
#  'cert_reqs': ssl.CERT_REQUIRED
#}


# load a default set of tasks?
CELERY_IMPORTS = ["runner.tasks", "runner.tasks_debug"]

#CELERY_RESULT_BACKEND = 'rpc://'
#CELERY_RESULT_SERIALIZER = 'json'
CELERY_RESULT_BACKEND = 'mongodb://abu1:27017'
#CELERY_RESULT_BACKEND = 'mongodb://172.17.0.3:27017'
CELERY_MONGODB_BACKEND_SETTINGS = {'database': 'jobs_completed', 'taskmeta_collection': 'celery_taskmeta'}


CELERY_TASK_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT=['json']
# CELERY_ACCEPT_CONTENT=['json', 'pickle']
CELERY_ENABLE_UTC = True


# route a misbhevaing task to a dedicated queue?
#CELERY_ROUTES = {
#    'tasks.add': 'low-priority',
#}

# rate limit tasks of type e.g. only 10 additions per minute
CELERY_ANNOTATIONS = {
    # overwrite default for all tasks
    '*': {'time_limit': 60.0},

    # other tasks
    # 'runner.tasks.add': {'rate_limit': '10/m'},

    # tasks for programming assignments
    'runner.tasks.compile': {'time_limit': 30.0},
    'runner.tasks.execute': {'time_limit': 30.0},
    'runner.tasks.grade': {'time_limit': 30.0},
}
