Process webhooks in the background

#1
by Wauplin HF staff - opened

(not tested but "should work")

When receiving a webhook, you should respond in less than 30s. If process takes longer than that, it's best to run it in a background task. You can use fastapi.BackgroundTasks for that. When you receive a webhook, you quickly check if it's a valid payload or not. If accepted, you schedule a task and return HTTP 202 (Accepted). Otherwise, you simply return a HTTP 200.

Inspired by https://huggingface.co/spaces/Wauplin/gradio-space-ci/blob/main/src/gradio_space_ci/webhook.py#L241.

derek-thomas changed pull request status to merged

Sign up or log in to comment