On Tue, Apr 21, 2020 at 1:39 AM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> I don't get this whole business of channels being associated
> with interpreters, or why there needs to be a distinction
> between release() and close().
>
> To my mind, a channel reference should be like a file
> descriptor for a pipe. When you've finished with it, you
> close() it. When the last reference to a channel is
> closed or garbage collected, the channel disappears.
> Why make it any more complicated than that?

You've mostly described what the PEP proposes: when all objects
wrapping a channel in an interpreter are destroyed, that channel is
automatically released.  When all interpreters have released the
channel then it is automatically closed.

The main difference is that the PEP also provides an way to explicitly
release or close a channel.  Providing just "close()" would mean one
interpreter could stomp on all other interpreters' use of a channel.
Working around that would require clunky coordination (likely through
other channels).  The alternative ("release()") is much simpler.

> You seem to be worried about channels getting leaked if
> someone forgets to close them. But it's just the same
> for files and pipes, and nobody seems to worry about
> that.

Fair enough. :)

-eric
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/D6ML5MST6ZJJP2WYGYQWOLLR6GGI6MMZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to