Skip to content

NVR with realtime local object detection for IP cameras

fix: run Frigate+ API calls in thread pool to prevent event loop bloc… (#22426)

padioca687fefb343ea
diff --git a/frigate/api/event.py b/frigate/api/event.py
index b0a7490186..567fe5a4b9 100644
--- a/frigate/api/event.py
+++ b/frigate/api/event.py
@@ -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,