Return response to Github in time, run our process as BackgroundTasks#756
Return response to Github in time, run our process as BackgroundTasks#756
Conversation
WalkthroughThe process_webhook endpoint in webhook_server/app.py was modified to accept a BackgroundTasks parameter and now schedules webhook processing as a background task instead of awaiting its completion, allowing the HTTP response to return immediately while processing continues asynchronously. Error handling was added inside the background task to log exceptions. Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (4)
🔇 Additional comments (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Report bugs in Issues The following are automatically added:
Available user actions:
PR will be approved when the following conditions are met:
Approvers and Reviewers
Supported /retest check runs
Supported labels
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
webhook_server/app.py (1)
153-154: Consider returning the actual task details in the response.The response currently returns a success status regardless of the actual outcome of the background processing.
Consider including the delivery ID or some other reference in the response that could be used to query the status of the background task later:
background_tasks.add_task(api.process) - return {"status": requests.codes.ok, "message": "process success", "log_prefix": delivery_headers} + return {"status": requests.codes.ok, "message": "webhook received, processing started", "delivery_id": delivery_id, "log_prefix": delivery_headers}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
webhook_server/app.py(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
webhook_server/app.py (1)
webhook_server/libs/github_api.py (1)
process(155-196)
🔇 Additional comments (2)
webhook_server/app.py (2)
11-11: LGTM! Import added for background task implementation.The import of
BackgroundTasksfrom FastAPI is necessary to implement the asynchronous processing approach described in the PR objectives.
124-124: LGTM! Function signature updated appropriately.The function signature has been updated to include
background_tasks: BackgroundTasksparameter, which FastAPI will automatically inject. This change is required to implement background processing.
|
/verified |
|
New container for ghcr.io/myk-org/github-webhook-server:latest published |
Github webhook need answer in 10 seconds, otherwise it report time out.
We return 200 if we got the hook and all check passed, otherwise we return error.
Summary by CodeRabbit