...
 
Commits (2)
......@@ -230,7 +230,7 @@ class WrappedLibrary(object):
warnings.warn("Could not ensure stack size, probably due to running on Windows. Expect segfaults soon.")
self.last_power = powerof2
def __del__(self):
def annihilate(self):
if self.remote:
try:
......@@ -240,6 +240,11 @@ class WrappedLibrary(object):
self.the_library.wait()
self.the_library.stdin.close()
self.the_library.stdout.close()
self.remote = False
def __del__(self):
self.annihilate()
if __name__ == '__main__':
......
......@@ -121,16 +121,26 @@ all_sessions = []
def cleanup_sessions():
# Deallocate patterns
for sess in all_sessions:
for ptr in sess.pattern_ptrs:
sess.lifelib('DeletePattern', ptr)
sess.pattern_ptrs = set([])
# Deallocate lifetrees
for sess in all_sessions:
for ptr in sess.lifetree_ptrs:
sess.lifelib('DeleteLifetree', ptr)
sess.lifetree_ptrs = set([])
# Wait for child processes
for sess in all_sessions:
sess.lifelib.annihilate()
# Remove references
while all_sessions:
all_sessions.pop()
atexit.register(cleanup_sessions)
class Session(object):
......
......@@ -66,3 +66,5 @@ printf "\n\033[1;36m **** segfault tests ****\033[0m\n"
for python_name in "${pythons[@]}"; do
"$python_name" -c 'import lifelib; lt = lifelib.load_rules("b3s23").lifetree(); pat = lt.pattern(); f = lambda x : x'
done
printf "\n\033[1mAll tests completed successfully.\033[0m\n"