[omniORB] (2nd posting) Python servant object deletion

Duncan Grisby dgrisby@uk.research.att.com
Tue, 29 May 2001 13:34:38 +0100


On Tuesday 29 May, "Davidson, Keith" wrote:

> I create a servant instance and later need to delete it.  I'm
> struggling to figure out how the standard CORBA lifecycle/memory
> management stuff maps to the python ORB.  Here is a sample class and
> factory:

[...]
> o Do I need to do something on the client side to deactivate ts?  I
> assume python ref counting is tied into the object reference so when
> ts goes out of scope the object ref count goes to 0 and no
> CORBA.release() call is needed!

Be careful not to confuse the life cycle of object references with the
life cycle of servants. Servants exist independently of any object
references referring to them. A servant is _never_ deleted due to the
release of an object reference.

> o Do I need to do something on the server side?

Yes. When you call _this() on the servant, the object is implicitly
activated in the Root POA. The POA now holds a (Python) reference to
the servant. You must deactivate the object so the POA releases its
reference:

    def killTestServant (self):
       print 'killing'
       id = poa.servant_to_id(self.mTestServant)
       poa.deactivate_object(id)
       self.mTestServant = None

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --