From 3cf9454da51f2a23cccb5a429aee24d89da76970 Mon Sep 17 00:00:00 2001 From: Brandon Castellano Date: Mon, 28 Mar 2022 18:29:32 -0400 Subject: [PATCH] Ensure `close` is called when Container is deleted Currently, close() is only called when using a context manager. This can demonstrably lead to hangs when using AUTO threading mode as shown in the cookbook example. As @jlaine discovered in #909, calling `close()` on the Container seems to resolve the issue, likely by making sure the threads have been joined by the time __dealloc__ runs. --- av/container/core.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/av/container/core.pyx b/av/container/core.pyx index 8c1136411..2b976c4c2 100755 --- a/av/container/core.pyx +++ b/av/container/core.pyx @@ -244,6 +244,9 @@ cdef class Container(object): # Finish releasing the whole structure. lib.avformat_free_context(self.ptr) + def __del__(self): + self.close() + def __enter__(self): return self