Sending a task by it's name
I'm looking for a way to send a task by it's name (something similar to send_task in Celery). I've tried to find something in docs, but didn't get anywhere.
The reason for this because I want to separate a worker from my main program to it's own service: it has some big dependencies I wouldn't want to include in the main project. They are only necessary for the worker, and that's it.
Is there a way to do such thing in Taskiq which I missed?
You can construct an AsyncKicker and kiq it as you'd do with task.
Here's how taskiq-pipelines does it: https://github.com/taskiq-python/taskiq-pipelines/blob/ef097a5baa3caf66b065fdddf5fbcbcac0b75532/taskiq_pipelines/pipeliner.py#L383.
You can construct an
AsyncKickerandkiqit as you'd do with task.Here's how taskiq-pipelines does it: https://github.com/taskiq-python/taskiq-pipelines/blob/ef097a5baa3caf66b065fdddf5fbcbcac0b75532/taskiq_pipelines/pipeliner.py#L383.
Thank you, it will work. Is there any chances for an easier method to be implemented (just like send_task in Celery)? You need to dig quite deep into the package to implement the functionality with AsyncKicker.
No it's actually not that deep in the package. So, in simple case it'd look like this:
kicked = await AsyncKicker(broker=broker, task_name="task_name", labels={}).kiq(*args, **kwargs)
But I'd generally advise to use tasks for better experience. If you don't have actual code, you can define placeholders with types as this:
@broker.task(task_name="external_task")
async def my_task(arg1: str, arg2: str = "test") -> None: ...
And use them as other tasks:
await my_task.kiq(1, arg2=22)
No it's actually not that deep in the package. So, in simple case it'd look like this:
kicked = await AsyncKicker(broker=broker, task_name="task_name", labels={}).kiq(*args, **kwargs)
Yes, thank you, it's quite simple. I meant for an abstract programmer it would take too much effort: there is nothing about it in the docs, so without this thread you would need to dig into the source code, find this class, by some way find out that it's what you need and do exactly the thing (docs only say "Class that used to modify data before sending it to broker.", unfortunately, which is quite short). At least some more info in the class would be great
But I'd generally advise to use tasks for better experience. If you don't have actual code, you can define placeholders with types as this:
@broker.task(task_name="external_task") async def my_task(arg1: str, arg2: str = "test") -> None: ... And use them as other tasks:
await my_task.kiq(1, arg2=22)
Yes, I like it better. Will use this approach. Thank you again
That's true. I'll add an article about this in docs. Please keep this issue open. I'll close it once it's in docs.
I'm glad I could help you. If you find this project useful, please consider supporting it.
Also, currently I'm gathering list of companies that use taskiq. I would really appreciate it if you could share a few words about your experience with TaskIQ and grant me permission to include your company in our list of our users.
Additionally, if you have any logos or a preferred way of showcasing your company on our website, please let me know — I’d be happy to represent you the way you want.
I'm glad I could help you. If you find this project useful, please consider supporting it.
Also, currently I'm gathering list of companies that use taskiq. I would really appreciate it if you could share a few words about your experience with TaskIQ and grant me permission to include your company in our list of our users.
Additionally, if you have any logos or a preferred way of showcasing your company on our website, please let me know — I’d be happy to represent you the way you want.
Apart from the topic, experience is pretty good. Haven't found anything concerning, the package feels stable and just works. Currently I'm using it for my own project, so I don't think you would want to add it to your list. But if it gets bigger - I'll let you know.
Hello @s3rius
I just discovered TaskIQ and I am trying to replace python-arq with it. It has all the features I need and it seems to work great. ( I lended on this topic because I need to launch task from an external API that doesn't import all my libraries)
I am using it at work for an internal tool for my team (1 API that receives cybersecurity alerts in JSON and then take action accordingly) I would be happy to test it and share my experience later this year