I am working on refactoring some code where the original author uses moviepy. So, I am not too familiar with the code usage, sorry.
I am having some problems that echo the problems described in #101, #110, #164, and #518. Examining the code, I believe they all have the same root cause.
Various classes (e.g. VideoFileClip) follow the same pattern:
I believe there are two misunderstandings here.
As a result, you are seeing Windows users complain that temporary files can't be deleted, and other users complaining that the number of "zombie" subprocesses is climbing as they continue processes.
The solution is:
The symptoms I am seeing, broadly:
Running Windows 10, Python 3.6.0. moviepy==0.2.3.2
I second that. I'd love to have a context manager that takes care of the cleanup.
My current solution is to explicitly calling __del__(), which is not very nice
Thanks very much for the insight @Julian-O. Let's maybe wait for one or two other opinions, but if it was all good, would you be able to clean the code and submit a PR ?
I agree.. I'd like to see if his suggestions will fix the issue. I don't see any harm in any of the things he is proposing.
@gyglim: Yes, I considered explicitly calling __del__() on VideoFileClip, but if you look at the code, it does nothing but call del on its subresources (which doesn't happen immediately), so the problem still remains.
I am underway with this change.
Here is my current understanding of how it will work.

Do you think we will be able to clearly explain to users which instances they need to call close() on, and when calling close() will also make the copies fail?
I still haven't touched the documentation. I don't want to pollute simple introductory examples with complexity they don't need, but I also want to demonstrate good, clean code that uses close() correctly.
Please tag a look at these changes, and tell me how you'd like to proceed. They have been swallowed up in a separate PR.
@Julian-O @earney Sorry for the late reaction, but is this issue solved at least on Gtihub now ? Looking at this thread I understand that there is an old PR pending. As there were two issues related to ffmpeg closing recently, what's the general opinion on merging @Julian-O 's solution ? (I haven't had time to review it all ad think of side effects but looks good at first sight)
@Zulko: I've been using my fork with the patches (and other patches documented in other pull requests) included, and it is passing tests and working fine for me. So, yes, it has been solved somewhere on GitHub, but not in the main branch yet.
sorry guys, which is the PR mentioned? close was implemented in 02fc129f, and that means this could be closed, right?
@Julian-O @mgaitan Any update on this?
@mgaitan, @keikoro:
The core functionality has been merged. However, some trivial formatting, spelling errors and the like remain unmerged in PR#608. It is sitting there, (forgotten?) but it isn't important enough to wave a flag about.
Linking this as I didn't see it linked upthread #608
@Julian-O Hmm, I see that one of the checks failed and that there was no follow-up on the code review (e.g. in form of a new commit), maybe that's why no-one continued looking into this
Most helpful comment
Thanks very much for the insight @Julian-O. Let's maybe wait for one or two other opinions, but if it was all good, would you be able to clean the code and submit a PR ?