Skip to content

Defer task on Django startup #1433

@eitchtee

Description

@eitchtee

I'm using Procrastinate on my Django application and I have a task that is ran periodically. What I would like to do is also run it when my app starts, after everything is correctly initialized. Something along the lines of @app.on_startup()

I've tried AppConfig.ready() and PROCRASTINATE_ON_APP_READY and both options seems to work, but besides raising a RuntimeWarning for accessing the database during app initialization, both are ran multiple times during the application's life-cycle including every time a worker is started using manage.py, which leads to multiple defers at the same time.

P.S.: Not sure if this is even possible as Django itself doesn't provide a proper way to detect when initialization is done, but would be nice if it was.

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