Author Henrique Andrade
Recipients Henrique Andrade, davin, pablogsal, pitrou
Date 2018-03-18.17:22:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CALAFW=BcgRmh_Np5UZr-vDOCebyN1ho0V80N-ypN_1-X1wF4sw@mail.gmail.com>
In-reply-to <1521393135.74.0.467229070634.issue33081@psf.upfronthosting.co.za>
Content
Your comparison is not correct.

RAII in C++ ensures that, on object destruction, resources that have been
acquired will be closed and deallocated.

The closest analogy in Python is the use of a context manager, which, btw,
a Queue does not provide.

Indeed, such a design (with a context manager) would have been cleaner
because, on exit, both pipes would have been closed and file descriptors
would not hang around.

And, yes, that is what I'd prefer too - but one can't have everything. :)

With the current design, which is more akin to Java, one is exposed to the
vagaries of the garbage collector. Note that, even in Java,
try-with-resources and the auto-closeable interface would also take care of
this. In fact, most the Java classes that require external resources have
migrated to this model.

For these reasons, I think the design could be substantially improved
(i.e., with a context manager or with the provision of a method that really
terminates the queue, so resources are properly closed immediately).

On Sun, Mar 18, 2018 at 1:12 PM, Pablo Galindo Salgado <
report@bugs.python.org> wrote:

>
> Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:
>
> >"I want to terminate the queue and make sure that no resources are leaked.
>
> Then you don't need to do anything special, those will be cleared on
> object destruction. This is not an unusual pattern even in other languages.
> For example, RAII in C++ is one of the most used patterns for acquiring
> resources and that works cleaning those resources on object destruction.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue33081>
> _______________________________________
>

-- 

Henrique Andrade | +1-530-426-2123 | hcma@unscrambl.com |
https://unscrambl.com
History
Date User Action Args
2018-03-18 17:22:06Henrique Andradesetrecipients: + Henrique Andrade, pitrou, davin, pablogsal
2018-03-18 17:22:06Henrique Andradelinkissue33081 messages
2018-03-18 17:22:06Henrique Andradecreate