Skip to content

Commit 0408ecd

Browse files
EstrellaXDclaude
andcommitted
fix(backend): use background task for startup to avoid blocking server
Change program.startup() to run via asyncio.create_task() so uvicorn accepts connections immediately while downloader check runs in background. Also add .claude/ project settings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3edddfe commit 0408ecd

2 files changed

Lines changed: 89 additions & 1 deletion

File tree

.claude/settings.local.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(git -C /Users/estrella/Developer/AutoBangumi/Auto_Bangumi log --oneline -10)",
5+
"Bash(git checkout:*)",
6+
"Bash(python -m pytest:*)",
7+
"Bash(python:*)",
8+
"Bash(uv init:*)",
9+
"Bash(uv sync:*)",
10+
"Bash(uv run pytest:*)",
11+
"Skill(feature-dev:feature-dev)",
12+
"Bash(uv pip install:*)",
13+
"Bash(uv run python:*)",
14+
"Bash(curl:*)",
15+
"Bash(pkill:*)",
16+
"Bash(uv pip show:*)",
17+
"Bash(uv pip list:*)",
18+
"Bash(uv lock:*)",
19+
"Bash(lsof:*)",
20+
"Bash(kill:*)",
21+
"Bash(VITE_API_URL=http://localhost:18080 pnpm dev:*)",
22+
"Bash(pnpm dev:*)",
23+
"Bash(pnpm add:*)",
24+
"Bash(git add:*)",
25+
"Bash(git commit:*)",
26+
"Skill(planning-with-files)",
27+
"Bash(../.venv/bin/python -m pytest test/test_database.py -v)",
28+
"Bash(.venv/bin/python:*)",
29+
"Bash(ruff check:*)",
30+
"Bash(ls:*)",
31+
"Bash(/Users/estrella/Developer/AutoBangumi/Auto_Bangumi/backend/.venv/bin/python:*)",
32+
"Bash(uv run ruff check:*)",
33+
"Bash(git rm:*)",
34+
"Bash(git push:*)",
35+
"Bash(gh pr create:*)",
36+
"Bash(gh pr checks:*)",
37+
"Bash(gh run view:*)",
38+
"Bash(git ls-tree:*)",
39+
"Bash(while read f)",
40+
"Bash(do git show \"HEAD:$f\")",
41+
"Bash(done)",
42+
"Bash(git reset:*)",
43+
"Skill(ui-ux-pro-max)",
44+
"Bash(tree:*)",
45+
"Bash(git stash:*)",
46+
"Bash(python3:*)",
47+
"Bash(pnpm build:*)",
48+
"Bash(pnpm install:*)",
49+
"Bash(uv venv:*)",
50+
"Bash(../.venv/bin/python:*)",
51+
"Bash(xargs:*)",
52+
"Skill(agent-browser)",
53+
"Bash(agent-browser open:*)",
54+
"Bash(agent-browser screenshot:*)",
55+
"Bash(agent-browser snapshot:*)",
56+
"Bash(agent-browser eval \"JSON.stringify\\(window.__consoleErrors || ''no errors captured''\\)\")",
57+
"Bash(agent-browser eval:*)",
58+
"Bash(agent-browser close:*)",
59+
"Bash(agent-browser reload:*)",
60+
"Bash(agent-browser fill:*)",
61+
"Bash(agent-browser click:*)",
62+
"Skill(commit-commands:commit)",
63+
"Bash(gh api:*)",
64+
"Bash(git fetch:*)",
65+
"Bash(git rebase:*)",
66+
"Bash(grep:*)",
67+
"Bash(git merge:*)",
68+
"Bash(agent-browser scroll:*)",
69+
"Bash(agent-browser find text \"Passkey Settings\" click)",
70+
"Bash(agent-browser find:*)",
71+
"Bash(agent-browser find text \"添加\" click)",
72+
"Bash(npx vue-tsc:*)",
73+
"Bash(npx vite build:*)",
74+
"WebSearch",
75+
"WebFetch(domain:bangumi.github.io)",
76+
"WebFetch(domain:raw.githubusercontent.com)",
77+
"WebFetch(domain:api.bgm.tv)",
78+
"Bash(__NEW_LINE_e2219f405dac932c__ echo \"\")",
79+
"Bash(__NEW_LINE_7c1bb4605ef4ad2a__ echo \"\")",
80+
"Bash(source ../.venv/bin/activate)",
81+
"Bash(source:*)",
82+
"Bash(npx vite:*)",
83+
"Bash(agent-browser press:*)",
84+
"Bash(agent-browser get:*)"
85+
]
86+
}
87+
}

backend/src/module/api/program.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import logging
23
import os
34
import signal
@@ -19,7 +20,7 @@
1920

2021
@router.on_event("startup")
2122
async def startup():
22-
await program.startup()
23+
asyncio.create_task(program.startup())
2324

2425

2526
@router.on_event("shutdown")

0 commit comments

Comments
 (0)