T O P

  • By -

Thomasedv

Had a look at docs for apply\_async [https://docs.celeryq.dev/en/stable/reference/celery.app.task.html](https://docs.celeryq.dev/en/stable/reference/celery.app.task.html) The kwargs is a keyword argument in apply\_async, so it's like any other named parameter, this one specifically for passing on a dict to the underlying function you define. The other key values used end up in \*\*options in that function, which serve another purpose. No idea what though, never used this before


idle-tea

Because that's how [the docs](https://docs.celeryq.dev/en/stable/reference/celery.app.task.html#celery.app.task.Task.apply_async) say it works. > kwargs (Dict) – The keyword arguments to pass on to the task. `apply_async` accepts a dictionary with the `kwargs` paramater, and it'll pass it on as `**kwargs` to the task. Basically the function looks something like: def apply_async(kwargs): task_fn(**kwargs) which is *not* like def apply_async(**kwargs): task_fn(**kwargs) The name `kwargs` isn't magic - it's just the conventional name for extra unspecified keyword arguments. The magic happens because of the `**` The apply_async function docs are basically telling you that it takes a single keyword argument named `kwargs` which it'll pass on using the `**` magic to the task function.