First I chain tasks like this
tasks_chain = chain(create_game_folder.si(instance.id))
tasks_chain |= download_game.si(instance.id).set(
task_id=str(task_id)
)
But I get this error
logger.debug(f"{game_id=}")
AttributeError: 'UUID' object has no attribute 'game_id'
This is how the create folder function starts
@shared_task()
def create_game_folder(game_id):
logger.info("create_game_folder")
logger.debug(f"{game_id=}")
game = Game.objects.get(id=game_id)
Why is it trying to get game_id from UUID? I know that instance.id returns a UUID object but if I do str(instance.id) I get AttributeError: 'str' object has no attribute 'game_id'
Is this something .si() or .delay() do in the background and for some reason the stacktrace is showing me the logger line?
Update:
/etc/systemd/system/celery.service
[Unit]
Description=Celery Service
Requires=django-app.service
After=django-app.service
[Service]
Type=forking
User=david
Group=vboxsf
RuntimeDirectory=celery
WorkingDirectory=/var/www/html/django-app.com
ExecStart=poetry run celery -A game_manager multi start worker --loglevel="INFO" --concurrency=5
ExecStop=poetry run celery multi stopwait worker --loglevel="INFO"
ExecReload=poetry run celery -A game_manager multi restart worker --loglevel="INFO" --concurrency=5
Restart=always
[Install]
WantedBy=multi-user.target
celery config
# Celery configuration
CELERY_BROKER_URL = "redis://localhost:6379"
CELERY_RESULT_BACKEND = "redis://localhost:6379"
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TIMEZONE = 'UTC'
CELERY_ENABLE_UTC = True
/etc/systemd/system/django-app.service
[Unit]
Description=Start Django app
After=network.target
[Service]
User=david
Group=david
Environment="PYTHONUNBUFFERED=TRUE"
WorkingDirectory=/var/www/html/django-app.com
ExecStart=poetry run gunicorn game_manager.wsgi:application --config game_manager/gunicorn_conf.py --reload
[Install]
WantedBy=multi-user.target
AttributeError: 'UUID' object has no attribute 'game_id'occurs, please?tasks_chainlater. Do you calldelay?tasks_chain.delay()now changed totransaction.on_commit(lambda: tasks_chain.delay())due to ATOMIC_REQUESTS being true.