-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kiq().with_labels(delay=X)
in documents not a valid invocation?
#279
Comments
I can't speak to the intent with regards to |
Ahhhh ... just read though it and see that its expected to be implemented at the broker layer. |
If you want to have delayed tasks, I'd suggest you to use scheduler and schedule task by time. The scheduler is compatible with any broker but it should run as a separate service. Here's the discussion with how you can use it. https://github.com/orgs/taskiq-python/discussions/275 I will update docs later. |
Do I get it right that scheduler polls sources once a minute so if I want to schedule a new task with a few seconds delay using |
No, you're correct. It will take up to minute for a default scheduler to send a task. If you want to add delay for few seconds I'd ask you to do something like this: import asyncio
from typing import Any, Coroutine
async def _sub_delay(seconds: int, future: Coroutine[Any, Any, Any]):
await asyncio.sleep(seconds)
await future
def delayed_await(seconds: int, future: Coroutine[Any, Any, Any]) -> asyncio.Task[Any]:
loop = asyncio.get_running_loop()
return loop.create_task(_sub_delay(seconds, future)) This thing allows you to create small delays before sending tasks on client's side without awaiting them. But be aware that such technique is good only for small delays. The usage is like this: delayed_await(3, my_task.kiq("arg1", 2)) |
The documentation for Kicker shows
.with_labels(delay=1)
:But this doesn't appear to be a valid invocation of
taskiq
, just purely an example with a label? This code, when set todelay=600
executes from theWorker
immedately, rather than after a delay.Is the intention to use the
Scheduler
to achieve this functionality? If so, the docs should probably removedelay
in favor of something else as a generic, sincedelay
seems to only be part ofcli.scheduler.run.delayed_send()
-- or better yet, maybedelay
should become a standard part of thekiq()
invocation to remove the dependancies on a single runningScheduler
if not looking for anything remotely crontab based and light weight, and is a cleaner resolution to #187 ?The text was updated successfully, but these errors were encountered: