Skip to content

Commit

Permalink
Ensure close is called when Container is deleted
Browse files Browse the repository at this point in the history
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 PyAV-Org#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.
  • Loading branch information
Breakthrough authored Mar 28, 2022
1 parent 0f36652 commit 3cf9454
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions av/container/core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3cf9454

Please sign in to comment.