code: def close(self, force=False):
          
          if self.running or force:
              self.running = False
              self.finished = True
  
              # Unregister for signals, which we registered for above with
              # `add_signal_watch`. (Without this, GStreamer leaks file
              # descriptors.)
              self.pipeline.get_bus().remove_signal_watch()
  
              # Stop reading the file.
              self.dec.set_property("uri", None)
              # Block spurious signals.
              self.sink.get_static_pad("sink").disconnect(self.caps_handler)
  
              # Make space in the output queue to let the decoder thread
              # finish. (Otherwise, the thread blocks on its enqueue and
              # the interpreter hangs.)
              try:
                  self.queue.get_nowait()
              except queue.Empty:
                  pass
  
              # Halt the pipeline (closing file).
              self.pipeline.set_state(Gst.State.NULL)
  
              # Delete the pipeline object. This seems to be necessary on Python
              # 2, but not Python 3 for some reason: on 3.5, at least, the
              # pipeline gets dereferenced automatically.
              del self.pipeline
docs: Close the file and clean up associated resources.
  
          Calling `close()` a second time has no effect.