Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #596: Add support for closing clips. #608

Closed
wants to merge 3 commits into from

Conversation

Julian-O
Copy link
Contributor

@Julian-O Julian-O commented Jul 3, 2017

  • Add key support for close()

    • FFMPEG_VideoWriter and FFMPEG_AudioWriter: Support close() and context managers.
    • Clip: support close() and context manager. Doesn't do anything itself. The work is done in the subclasses that need it.
    • Clip subclasses: Overrride close.
      • Move away from depending on clients calling__del__(). Deleting can be left to Garbage Collector.
    • CompositeVideoClip: Note: Don't close anything that wasn't constructed here. The client needs to be able to control the component clips.
    • AudioFileClip: Was concerned that lambda might include a reference to reader that wasn't cleaned up by close, so changed it over to an equivalent self.reader. Probably has no effect, but feels safer.
  • Update tests to use close().

  • Add two new test files:

    • test_resourcereleasedemo exercises the path where close is not called and demonstrates that there is a consistent problem on Windows. Even after this fix, it remains a problem that if you don't call close, moviepg will leak locked files and subprocesses. Because the problem remains until the process ends, this is included in a separate test file.]
    • test_resourcerelease demonstrates that when close() is called, the problem goes away.
  • Update documentation to include usage tips for close()

Not included:

  • Example code has not been updated to use close().

* Add key support for close()

   * FFMPEG_VideoWriter and FFMPEG_AudioWriter: Support close() and context managers.
   * Clip: support close() and context manager. Doesn't do anything itself. The work is done in the subclasses that need it.
   * Clip subclasses: Overrride close.
       * Move away from depending on clients calling__del__(). Deleting can be left to Garbage Collector.
   * CompositeVideoClip: Note: Don't close anything that wasn't constructed here. The client needs to be able to control the component clips.
   * AudioFileClip:  Was concerned that lambda might include a reference to reader that wasn't cleaned up by close, so changed it over to an equivalent self.reader. Probably has no effect, but feels safer.

* Update tests to use close().

   * Note: While many tests pass on Linux either way, a large proportion of the existing unit tests fail on Windows without these changes.
   * Include changes to many doctest examples - Demonstrate good practice in the examples.
   * Also, migrate tests to use TEMPDIR where they were not using it.
   * test_duration(): also corrected a bug in the test (described in Zulko#598). This bug is also been addressed in Zulko#585, so a merge will be required.

* Add two new test files:

   *  test_resourcereleasedemo exercises the path where close is not called and demonstrates that there is a consistent problem on Windows. Even after this fix, it remains a problem that if you don't call close, moviepg will leak locked files and subprocesses. Because the problem remains until the process ends, this is included in a separate test file.]
   * test_resourcerelease demonstrates that when close() is called, the problem goes away.

* Update documentation to include usage tips for close()

Not included:

    *  Example code has not been updated to use close().
@Julian-O Julian-O changed the title Issue #596: Add initial support for closing clips. Issue #596: Add support for closing clips. Jul 3, 2017
@coveralls
Copy link

coveralls commented Jul 3, 2017

Coverage Status

Coverage increased (+0.07%) to 54.151% when pulling 53c60b4 on Julian-O:Issue596 into 6ba12d0 on Zulko:master.

@kencochrane
Copy link
Contributor

Thank you for adding this, the code looks good to me, but I'm not a contributor, so we will need a contributor to review as well.

@tburrows13 tburrows13 added the feature New addition to the API i.e. a new class, method or parameter. label Jul 8, 2017
@coveralls
Copy link

coveralls commented Jul 8, 2017

Coverage Status

Coverage decreased (-0.2%) to 61.774% when pulling 4bb3530 on Julian-O:Issue596 into 6cbd4f3 on Zulko:master.

def __enter__(self):
return self

def __exit__(self, exc_type, exc_value, traceback):
self.close()

def __exit__(self, exc_type, exc_value, traceback):
Copy link
Collaborator

@mgaitan mgaitan Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is repeated, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Well spotted. That is an error. (It is of no consequence, but one should be deleted.)

@Gronis
Copy link

Gronis commented Jan 8, 2020

Hi,

Why is this issue closed? Is it fixed somewhere else?

EDIT: Oh, It looks like it was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition to the API i.e. a new class, method or parameter.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants