Commit 586ecc93 authored by Adam P. Goucher's avatar Adam P. Goucher

Also wait for child processes to terminate

parent 59343342
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment