Forums

Why my django-q tasks always shut down nearby 2 A.M. ?

This problem follow me for few days, I don't know how django-q work actually. Sometimes it's work normally for 2~3 days and shut down nearby 2 A.M (UTC+8). Now is shut down everyday. My CPU usage is enough, and nothing write in error log. Can anyone tell me what's going on with this problem or just my setting problem ?

How are you running the queue handler?

Using the console in my virtualenv : python manage.py qcluster. It's should be running my program every 10 mins once forever. my django setting like this below.

CACHES = {
    "default": {
        'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
        'LOCATION': 'django_cache',
    },
}


Q_CLUSTER = {
    'name': 'update_report',
    'workers': 1,
    'timeout': 90,
    'retry': 120,
    'queue_limit': 50,
    'bulk': 10,
    'orm': 'default',
    'has_replica': True
}

Our consoles are ephemeral by design -- you should try always-on task instead.

I see, but how to run my django-q tasks with always-on task ?

This help page describes how to use always on tasks: https://help.pythonanywhere.com/pages/AlwaysOnTasks/