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

Davidson, Keith kbd@iti-oh.com
Tue, 29 May 2001 08:21:44 -0400


Hi, I posted this a few days ago to the mailing list but did not have any replies.  I would be most appreciative if someone could take a quick look and point me in the right direction.

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:

class TestServant_i (Test__POA.TestServant):
    def __init__ (self):
       print "==== ctor"
       
    def __del__ (self):
       print "==== dtor"
       Test__POA.TestServant.__del__(self)

class TestServantFactory_i (Test__POA.TestServantFactory):
    def newTestServant (self):
       self.mTestServant = TestServant_i()
       return self.mTestServant._this()  # If I return None here, things work fine

    def killTestServant (self):
       print 'killing'
       self.mTestServant = None   #### Does not seem to kill the object!

Here is the client code:

============================
def createTestServant(factory):
   ts = factory.newTestServant()

... standard orb locating code using name services ...

createTestServant(tsf)  # tsf is a TestServantFactory found via name services
tsf.killTestServant()
============================

I have the call to newTestServant() inside a function to ensure the returned object goes out of scope before the call to killTestServant().  The "dtor" message never gets printed *unless* I change newTestServant to return a None.

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!

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

Please cc my direct email (kbd@iti-oh.com) as I just subscribed to this list in digest form and I'm anxiously awaiting help ;-)

Thanks,
Keith