A class to take responsibility for closing a stream on JVM shutdown. On creation a Closer adds
itself to a list that will be run by PySystemState on shutdown and it maintains a reference to
its client PyIOBase. The client (assuming it kept a reference to the Closer) may dismiss the
closer at any time: normally this will be when the client stream is closed directly, or
implicitly through
PyIOBase#__exit__(PyObject, PyObject, PyObject). A possibility is that
the JVM exits before an
close() is called. In that case,
Closer#call() will
be called, and the
Closer will call the client's close operation.
In case the close operation is overridden so that it does not dismiss the closer, it is useful to
have the client's finalize dismiss the closer. If not, the Closer will remain registered and this
will keep the PyIOBase object alive in the JVM, which is mostly harmless.