views:

59

answers:

1

I'm using parallel-python and start a new job server in a function. after the functions ends it still exists even though I didn't return it out of the function (I used weakref to test this). I guess there's still some references to this object somewhere. My two theories: It starts threads and it logs to root logger.

My questions: can I somehow findout in which namespace there is still a reference to this object. I have the weakref reference. Does anyone know how to detach a logger? What other debug suggestions do people have?

here is my testcode:

def pptester():

    js=pp.Server(ppservers=nodes)
    js.set_ncpus(0)
    fh=file('tmp.tmp.tmp','w')  
    tmp=[]
    for i in range(200):
        tmp.append(js.submit(ppworktest,(),(),('os','subprocess')))
    js.print_stats()
    return weakref.ref(js)

thanks in advance Wolfgang

+1  A: 

You can use gc.get_referrers(obj) to find out what is referencing the object. Because you'll most likely get a bunch of dicts as the response, you'll have to go up a couple of levels to make any sense of it.

Ants Aasma
that worked. found out that the package used atexit module. thanks for your help