Refactor async ONVIF (#18093)

* use async/await instead of asyncio.run()

* fix autotracking

* create cameras in same event loop that will use them

* more debug

* try using existing event loop instead of creating a new one

* merge dev

* fixes

* run get_camera_info onvifcontroller calls in dedicated loop

* move coroutine call with loop to api

* use asyncio for autotracking move queues

* clean up

* fix calibration

* improve exception logging
This commit is contained in:
Josh Hawkins
2025-05-07 07:53:29 -06:00
committed by GitHub
parent 83188e7ea4
commit da1fb935b4
4 changed files with 208 additions and 135 deletions
+6 -2
View File
@@ -1,5 +1,6 @@
"""Image and video apis."""
import asyncio
import glob
import logging
import math
@@ -110,9 +111,12 @@ def imagestream(
@router.get("/{camera_name}/ptz/info")
async def camera_ptz_info(request: Request, camera_name: str):
if camera_name in request.app.frigate_config.cameras:
return JSONResponse(
content=await request.app.onvif.get_camera_info(camera_name),
# Schedule get_camera_info in the OnvifController's event loop
future = asyncio.run_coroutine_threadsafe(
request.app.onvif.get_camera_info(camera_name), request.app.onvif.loop
)
result = future.result()
return JSONResponse(content=result)
else:
return JSONResponse(
content={"success": False, "message": "Camera not found"},