【发布时间】:2009-10-15 22:52:42
【问题描述】:
我需要抢占__del__,我想知道什么是正确的方法。基本上我的代码问题是这样的..
class A:
def __init__(self):
self.log = logging.getLogger()
self.log.debug("In init")
self.closed = False
def close(self):
self.log.debug("Doing some magic")
self.closed = True
def __del__(self):
if not self.closed:
self.close()
self.log.debug("In closing")
# What should go here to properly do GC??
现在有什么方法可以调用标准的 GC 功能吗?
感谢阅读!!
史蒂夫
【问题讨论】:
-
抢占?为什么?你到底想达到什么目的?