-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi! Hmm, it indeed seems I have forgotten to mention about the @app.task(permanent_task=True, on_startup=True, execution="async")
async def do_constantly():
while True:
...
await asyncio.sleep(0) There are a couple of reasons to use this. Without it, the task risks being timeout. If you put infinite as the timeout, there is a problem in the shutdown: the scheduler waits for the task to finish by default (which will never happen). This attribute signals to the scheduler that the task should never timeout but it should not wait it to finish when the scheduler shuts down. You can use any execution with the task except I possibly rename the Did I answer to the question? |
Beta Was this translation helpful? Give feedback.
Hi!
Hmm, it indeed seems I have forgotten to mention about the
permanent_task
:There are a couple of reasons to use this. Without it, the task risks being timeout. If you put infinite as the timeout, there is a problem in the shutdown: the scheduler waits for the task to finish by default (which will never happen). This attribute signals to the scheduler that the task should never timeout but it should not wait it to finish when the scheduler shuts down.
You can use any execution with the task except
main
as then the task blocks everythin…