mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-07 00:06:57 +01:00
reduce contention on frame_queue (#6890)
* reduce contention on frame_queue don't check if the queue is full, just attempt to add the frame in a non-blocking manner, and then if it fails, skip it * don't check if the frame queue is empty, just try and get from it * Update frigate/video.py Co-authored-by: Blake Blackshear <blakeb@blakeshome.com> --------- Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
This commit is contained in:
parent
c38c981cd0
commit
2fae9dcb93
@ -206,17 +206,16 @@ def capture_frames(
|
|||||||
|
|
||||||
frame_rate.update()
|
frame_rate.update()
|
||||||
|
|
||||||
# if the queue is full, skip this frame
|
# don't lock the queue to check, just try since it should rarely be full
|
||||||
if frame_queue.full():
|
try:
|
||||||
skipped_eps.update()
|
# add to the queue
|
||||||
frame_manager.delete(frame_name)
|
frame_queue.put(current_frame.value, False)
|
||||||
continue
|
|
||||||
|
|
||||||
# close the frame
|
# close the frame
|
||||||
frame_manager.close(frame_name)
|
frame_manager.close(frame_name)
|
||||||
|
except queue.Full:
|
||||||
# add to the queue
|
# if the queue is full, skip this frame
|
||||||
frame_queue.put(current_frame.value)
|
skipped_eps.update()
|
||||||
|
frame_manager.delete(frame_name)
|
||||||
|
|
||||||
|
|
||||||
class CameraWatchdog(threading.Thread):
|
class CameraWatchdog(threading.Thread):
|
||||||
@ -757,13 +756,15 @@ def process_frames(
|
|||||||
region_min_size = get_min_region_size(model_config)
|
region_min_size = get_min_region_size(model_config)
|
||||||
|
|
||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
if exit_on_empty and frame_queue.empty():
|
|
||||||
logger.info("Exiting track_objects...")
|
|
||||||
break
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if exit_on_empty:
|
||||||
|
frame_time = frame_queue.get(False)
|
||||||
|
else:
|
||||||
frame_time = frame_queue.get(True, 1)
|
frame_time = frame_queue.get(True, 1)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
|
if exit_on_empty:
|
||||||
|
logger.info("Exiting track_objects...")
|
||||||
|
break
|
||||||
continue
|
continue
|
||||||
|
|
||||||
current_frame_time.value = frame_time
|
current_frame_time.value = frame_time
|
||||||
|
Loading…
Reference in New Issue
Block a user