keep_alive call policy (analogous to Boost.Python's with_custodian_and_ward, fixes #62)

This commit is contained in:
Wenzel Jakob
2016-01-17 22:31:15 +01:00
parent 87187afe91
commit 5f218b3f2c
8 changed files with 208 additions and 4 deletions
+46
View File
@@ -0,0 +1,46 @@
from __future__ import print_function
import sys
import gc
sys.path.append('.')
from example import Parent, Child
if True:
p = Parent()
p.addChild(Child())
gc.collect()
print(p)
p = None
gc.collect()
print("")
if True:
p = Parent()
p.returnChild()
gc.collect()
print(p)
p = None
gc.collect()
print("")
if True:
p = Parent()
p.addChildKeepAlive(Child())
gc.collect()
print(p)
p = None
gc.collect()
print("")
if True:
p = Parent()
p.returnChildKeepAlive()
gc.collect()
print(p)
p = None
gc.collect()
print("")
print("Terminating..")