mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-19 19:06:16 +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()
|
||||
|
||||
# if the queue is full, skip this frame
|
||||
if frame_queue.full():
|
||||
# don't lock the queue to check, just try since it should rarely be full
|
||||
try:
|
||||
# add to the queue
|
||||
frame_queue.put(current_frame.value, False)
|
||||
# close the frame
|
||||
frame_manager.close(frame_name)
|
||||
except queue.Full:
|
||||
# if the queue is full, skip this frame
|
||||
skipped_eps.update()
|
||||
frame_manager.delete(frame_name)
|
||||
continue
|
||||
|
||||
# close the frame
|
||||
frame_manager.close(frame_name)
|
||||
|
||||
# add to the queue
|
||||
frame_queue.put(current_frame.value)
|
||||
|
||||
|
||||
class CameraWatchdog(threading.Thread):
|
||||
@ -757,13 +756,15 @@ def process_frames(
|
||||
region_min_size = get_min_region_size(model_config)
|
||||
|
||||
while not stop_event.is_set():
|
||||
if exit_on_empty and frame_queue.empty():
|
||||
logger.info("Exiting track_objects...")
|
||||
break
|
||||
|
||||
try:
|
||||
frame_time = frame_queue.get(True, 1)
|
||||
if exit_on_empty:
|
||||
frame_time = frame_queue.get(False)
|
||||
else:
|
||||
frame_time = frame_queue.get(True, 1)
|
||||
except queue.Empty:
|
||||
if exit_on_empty:
|
||||
logger.info("Exiting track_objects...")
|
||||
break
|
||||
continue
|
||||
|
||||
current_frame_time.value = frame_time
|
||||
|
Loading…
Reference in New Issue
Block a user