문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top