Skip to content

How to block a task until it's finished ? #426

@sorasful

Description

@sorasful

Hi there!

I was trying to wait for a task to finish before going further, and I thought that wait_result() was for this purpose. But it seems that it does not block. Here's my setup .

# import related stuff ...

settings = get_settings()

broker = ListQueueBroker(
    url=settings.redis.URL,
)

scheduler = TaskiqScheduler(
    broker=broker,
    sources=[LabelScheduleSource(broker)],
)


@broker.task(task_name="process_video")
async def process_video(video_id: uuid.UUID):
    """Main task to process a YouTube video."""
    print('WAITING')
    await asyncio.sleep(10)
    print("DONE WAITING")
    return



if __name__ == "__main__":
    async def main() -> None:
        process_task = await process_video.kiq(video_id="hdd")
        await process_task.wait_result()
    
        print("DONE")

The thing is that my task is indeed triggered and takes 10 seconds. But I see the "DONE" print immediately, I would know if it's possible to block it until it's done, I tried to setup timeout params but it's the same.

Thanks for your time !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions