mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-07 03:11:15 +03:00
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:
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user