[Bugfix][Multimodal] Invalidate retained PyNvVideoCodec decoder after failure (#51139)

Signed-off-by: Dat Mai <dmai@nvidia.com>
This commit is contained in:
dmai-afk
2026-08-12 11:02:10 +00:00
committed by GitHub
parent 86e2ab50aa
commit 4c51ceb11b
3 changed files with 134 additions and 1 deletions
+11 -1
View File
@@ -261,8 +261,13 @@ class PyNvVideoCodecDecoderSlot:
self.decoder = None
self.source_path: str | None = None
def invalidate(self) -> None:
self.decoder = None
self.source_path = None
def _construct(self, file_path: str, nvc, device_index: int) -> None:
self.decoder = nvc.SimpleDecoder(
self.invalidate()
decoder = nvc.SimpleDecoder(
file_path,
output_color_type=nvc.OutputColorType.RGB,
use_device_memory=True,
@@ -271,6 +276,7 @@ class PyNvVideoCodecDecoderSlot:
cuda_stream=self.stream.cuda_stream,
decoder_cache_size=PYNVVIDEOCODEC_DECODER_CACHE_SIZE,
)
self.decoder = decoder
self.source_path = file_path
def get_decoder(self, file_path: str, nvc, device_index: int):
@@ -747,9 +753,13 @@ class PyNvVideoCodecVideoBackendMixin:
cls._decoder_slot_cond.notify()
raise
borrow_succeeded = False
try:
yield slot
borrow_succeeded = True
finally:
if not borrow_succeeded:
slot.invalidate()
with cls._decoder_slot_cond:
cls._decoder_slots.append(slot)
cls._decoder_slot_cond.notify()