Skip to content

Add asynchronous task execution#667

Open
mxsrc wants to merge 5 commits intodevfrom
celery
Open

Add asynchronous task execution#667
mxsrc wants to merge 5 commits intodevfrom
celery

Conversation

@mxsrc
Copy link
Collaborator

@mxsrc mxsrc commented Mar 17, 2026

This adds support for asynchronous background tasks. FastAPI's native support for these is limited: The builtin background tasks are anonymous background workers. They have no identity that can be used to communicate ongoing process, and they are lost on restarts.

Instead, this changeset introduces the use of celery, which is the go-to for these tasks in the Python ecosystem. The deployment includes an additional worker container that picks up tasks. The broker and result backend use the existing postgres database, alternatives are available.

To confirm the new approach works as intended, the resizing is converted to use celery tasks. Future changes will convert other potentially long-running tasks, in particular anything concerning branch lifecycle management, and ideally monitoring and recurring tasks like backup cleanup and scheduled snapshot creation.

The resize operation now starts individual resizes for each of the affected resources, awaits all results and writes the new values to the database. The ID of the ongoing resize task is stored into the database entity, and the RESIZING status is derived from this. The task itself cleans this up upon completion.

@mxsrc mxsrc added the deploy label Mar 17, 2026
Base automatically changed from dev to main March 19, 2026 14:34
@mxsrc mxsrc changed the base branch from main to dev March 21, 2026 23:15
@mxsrc mxsrc removed the deploy label Mar 21, 2026
@mxsrc mxsrc added the deploy label Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant