Skip to content

Commit 3ec99f8

Browse files
committed
[tests] Fix fanout behavior for testing
1 parent 925bf70 commit 3ec99f8

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

scenedetect/_fan_out.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,19 @@ def _read_loop(self) -> None:
139139
except BaseException as e:
140140
self._reader_exc = e
141141
finally:
142-
# Sentinel must reach every consumer or its blocking read() deadlocks.
143-
# Drop the oldest frame whenever the queue is full; we are the sole writer,
144-
# so after a successful get_nowait() the queue has room for the EOF.
142+
# Sentinel must reach every consumer or its blocking read() deadlocks. On normal
143+
# EOF the put must respect back-pressure (a full queue still holds undelivered
144+
# frames); only once an abort is in progress may pending frames be dropped to
145+
# force the sentinel through.
145146
for q in self._queues:
146147
while True:
147148
try:
148-
q.put_nowait(_EOF)
149+
q.put(_EOF, timeout=0.1)
149150
break
150151
except queue.Full:
151-
with contextlib.suppress(queue.Empty):
152-
q.get_nowait()
152+
if self._stop.is_set():
153+
with contextlib.suppress(queue.Empty):
154+
q.get_nowait()
153155

154156

155157
class _FanOutConsumer(VideoStream):

0 commit comments

Comments
 (0)