speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a memory leak in the Python library


From: Rui Batista
Subject: a memory leak in the Python library
Date: Sat, 31 Jul 2010 13:23:49 +0100

Hi,

Some comments:
S?b, 2010-07-31 ?s 05:38 -0500, Chris Brannon escreveu:
> I wrote:
> > The solution is to simply execute
> > del self._conn
> > at the end of SSIPClient.close().  I think this is completely safe.
> 
> Also, self._conn should probably be a weak reference.  Otherwise, the
> following snippet of code is not exception-safe.
> 
> c = SSIPClient('foo')
> c.speak('Hello, world!')
> # If c.speak raises an exception, this next statement is never executed, and
> # thus c will never be collected:
> c.close()
> 
Agreed.


> We might also want to think about adding the __enter__ and __exit__ methods
> to SSIPClient, so that people can use the "with" statement described in
> PEP 0343.  Python's "with" statement gives us  something
> similar to RAII in C++.
> 
This is good but we might have a problem. Python's with statement is
present just in python 2.6 and above, if we implement just the methods
we can be compatible with python 2.5 and bellow, but we should not use
with statements in our code because of python 2.5 compatibility. When I
say "our" means speech-dispatcher's code :)

Rui Batista

> -- Chris
> 
> _______________________________________________
> Speechd mailing list
> Speechd at lists.freebsoft.org
> http://lists.freebsoft.org/mailman/listinfo/speechd





reply via email to

[Prev in Thread] Current Thread [Next in Thread]