from celery.task import task
from corehq.apps.users.models import CommCareUser


@task
def create_user_cases(domain_name):
    from corehq.apps.callcenter.utils import sync_usercase
    for user in CommCareUser.by_domain(domain_name):
        sync_usercase(user)

from celery.task import task
from corehq.apps.users.models import CommCareUser


@task(queue='background_queue')
def create_user_cases(domain_name):
    from corehq.apps.callcenter.utils import sync_usercase
    for user in CommCareUser.by_domain(domain_name):
        sync_usercase(user)

Use background queue for creating user cases
Use background queue for creating user cases
