【发布时间】:2018-11-29 11:20:43
【问题描述】:
请查看以下代码...
class Client(MqC):
def __init__(self, tmpl=None):
self.ConfigSetBgError(self.BgError)
MqC.__init__(self)
def BgError(self):
... do some stuff……
我可以将回调 BgError 添加为类或对象回调...
- class=
self.ConfigSetBgError(Client.BgError) - 对象 =
self.ConfigSetBgError(self.BgError)
这两种情况都有效,因为回调代码可以处理此问题
问题是 self 对象的 refCount ......情况(2)将 refCount 增加 ONE…所以下面的代码显示了差异代码…
cl = Client()
print("refCount=" + str(sys.getrefcount(cl)))
cl = None
-
.tp_dealloc被称为...因为refCount=2 -
.tp_dealloc被 不 调用,因为refCount=3
→ 所以……问题……如何解决这个 refCount 清理问题?
【问题讨论】:
-
请不要用C标记有关python的问题。谢谢。
标签: python automatic-ref-counting