Implementing reference count.

Laurent Brack <[email protected]>
Newsgroups gmane.comp.python.pyro
Message-ID <CAO0-goN0ixB-ouNBpO5yFe6kTi1AuMrEsxsa3-J5uVX4RDTwVg@mail.gmail.com>
Hello,

I am attempting (without success so far) to maintain a reference count on
objects that are
created from a factory.

What I am looking for is a way to release the object when the Pyro Proxy is
released on
the client side (i.e. set to None and python does its thing with GB).

Suppose that I have class A (which is registered with the name server) that
acts as an
object factory, when I request an instance of say class B, the following
happens.

I register the instance of B() with the daemon, and instantiate a Pyro
Proxy (with the uri
resulting from the registration) which I return as opposed to the object
B() itself.

when the client calls the B::release(), the object deregisters itself with
the Pyro server
daemon and python garbage collects B() on the server side (with a dandling
ref on the client side).

This works great. However, I can not expect people to explicitly call the
B::release(), so I
thought I would be smart and simply subclass Pyro.core.Proxy to take
care of this in the
destructor for them ... I wasn't smart as it hangs when when attempt to
return the proxy
from the server side...

the destructor looks like this (simplified)

def __del__(self):
   self._elab_release_ref()
   Pyro4.core.Proxy.__del__(self)

as I am writing this I remember that my server type is multiplex (no thread
pool) and I believe
that the self._elab... causes the server to call itself and block.

Regardless, it is clear to me that what I am doing is wrong and I was
wondering if anyone
had an idea on how this should be done.

Thanks in advance.

/Laurent

------------------------------------------------------------------------------
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

_______________________________________________
Pyro-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyro-core
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.