Re: Implementing reference count.

Irmen de Jong <[email protected]>
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
On 12-10-2012 3:56, Laurent Brack wrote:

> the destructor looks like this (simplified)
> 
> def __del__(self):
>    self._elab_release_ref()
>    Pyro4.core.Proxy.__del__(self)


For now, only a general note:

Please be aware that Python doesn't give any guarantee on when __del__ is actually
called. It might never be called at all. So it is almost always better to do explicit
cleanup anyway.

I would suggest implementing the contextmanager protocol instead (__enter__ / __exit__)
so that you can use your objects in a 'with'. (And have explicit cleanup at leaving the
block, from witin the __exit__ method. It might just call self.release() or something).


Irmen


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.