cancel token_worker_task only if running

This commit is contained in:
Alpha Nerd 2025-11-14 15:53:26 +01:00
parent b9933e000f
commit 4c7ebb5af4
2 changed files with 18 additions and 3 deletions

14
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,14 @@
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Python File",
"type": "debugpy",
"request": "launch",
"program": "${file}"
}
]
}

View file

@ -1411,7 +1411,7 @@ async def openai_embedding_proxy(request: Request):
# 2. Endpoint logic
endpoint = await choose_endpoint(model)
await increment_usage(endpoint, model)
if "/v1" in endpoint and is_ext_openai_endpoint(endpoint):
if "/v1" in endpoint: # and is_ext_openai_endpoint(endpoint):
api_key = config.api_keys[endpoint]
else:
api_key = "ollama"
@ -1700,7 +1700,7 @@ async def health_proxy(request: Request):
* The HTTP status code is 200 when everything is healthy, 503 otherwise.
"""
# Run all health checks in parallel
tasks = [fetch.endpoint_details(ep, "/api/version", "version") for ep in config.endpoints if not is_ext_openai_endpoint(ep)]
tasks = [fetch.endpoint_details(ep, "/api/version", "version") for ep in config.endpoints] # if not is_ext_openai_endpoint(ep)]
results = await asyncio.gather(*tasks, return_exceptions=True)
@ -1786,4 +1786,5 @@ async def startup_event() -> None:
async def shutdown_event() -> None:
await close_all_sse_queues()
await app_state["session"].close()
token_worker_task.cancel()
if token_worker_task is not None:
token_worker_task.cancel()