farahats9 / sqlalchemy-celery-beat

Celery Periodic Tasks backed by the SQLAlchemy
MIT License
43 stars 6 forks source link

Passing a dict as an argument to a task #6

Closed miguelvalente closed 6 months ago

miguelvalente commented 6 months ago

Hey, again @farahats9. 'm trying to pass a dictionary as an argument to a scheduled task:

asd = {
    "x": 5,
    "y": 5
}

import json
task = PeriodicTask(
    schedule_model=schedule,
    name='Adding to 10',
    task='main.add',
    args=json.dumps(asd)
)

It's saved with a dict structure,

Screenshot 2024-03-04 at 16 27 34

But on the receiving end only the keys are provided.

Screenshot 2024-03-04 at 16 36 17

Is this a limitation imposed by sqlalchemy-celery-beat or by celery? Still not very sure where the line between the two is.

miguelvalente commented 6 months ago

never mind I'm an idiot. Forgot about kwargs for 30 minutes.

task = PeriodicTask(
    schedule_model=schedule,
    name='Adding to 10',
    task='main.add',
    kwargs=json.dumps(asd),
)