fix: run Frigate+ API calls in thread pool to prevent event loop bloc… (#22426)
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions

This commit is contained in:
padioca 2026-03-14 15:31:33 -05:00 committed by GitHub
parent 7864c446fc
commit 687fefb343
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
"""Event apis."""
import asyncio
import base64
import datetime
import json
@ -1124,7 +1125,9 @@ async def send_to_plus(request: Request, event_id: str, body: SubmitPlusBody = N
)
try:
plus_id = request.app.frigate_config.plus_api.upload_image(image, event.camera)
plus_id = await asyncio.to_thread(
request.app.frigate_config.plus_api.upload_image, image, event.camera
)
except Exception as ex:
logger.exception(ex)
return JSONResponse(
@ -1140,7 +1143,8 @@ async def send_to_plus(request: Request, event_id: str, body: SubmitPlusBody = N
box = event.data["box"]
try:
request.app.frigate_config.plus_api.add_annotation(
await asyncio.to_thread(
request.app.frigate_config.plus_api.add_annotation,
event.plus_id,
box,
event.label,
@ -1230,7 +1234,8 @@ async def false_positive(request: Request, event_id: str):
)
try:
request.app.frigate_config.plus_api.add_false_positive(
await asyncio.to_thread(
request.app.frigate_config.plus_api.add_false_positive,
event.plus_id,
region,
box,