fix: lifespan 关闭时 await 取消的采集任务,避免 pending 警告
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,10 @@ async def lifespan(app: FastAPI):
|
|||||||
yield
|
yield
|
||||||
finally:
|
finally:
|
||||||
collector_task.cancel()
|
collector_task.cancel()
|
||||||
|
try:
|
||||||
|
await collector_task
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(title="AUV API", version="1.0.0", lifespan=lifespan)
|
app = FastAPI(title="AUV API", version="1.0.0", lifespan=lifespan)
|
||||||
|
|||||||
Reference in New Issue
Block a user