If an exception is raised in a test, its traceback contains references to objects used in the test. These references prevent garbage collection of the objects. Normally this isn't a problem because when a program exits the objects are garbage-collected anyway, but fork_start() calls os._exit() which skips normal exit processing. Thus we can't rely on objects' __del__() methods being called.
The problem can be solved by calling sys.exc_clear() to clear exception information before exiting. It also doesn't hurt to call gc.collect() just to be very sure that garbage collection takes place. Signed-off-by: Michael Goldish <[email protected]> --- client/bin/parallel.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/client/bin/parallel.py b/client/bin/parallel.py index 1ecc75f..47dd5cd 100644 --- a/client/bin/parallel.py +++ b/client/bin/parallel.py @@ -2,7 +2,7 @@ __author__ = """Copyright Andy Whitcroft 2006""" -import sys, logging, os, pickle, traceback +import sys, logging, os, pickle, traceback, gc from autotest_lib.client.common_lib import error, utils def fork_start(tmp, l): @@ -39,6 +39,10 @@ def fork_start(tmp, l): sys.stdout.flush() sys.stderr.flush() finally: + # clear exception information to allow garbage collection of + # objects referenced by the exception's traceback + sys.exc_clear() + gc.collect() os._exit(1) else: try: -- 1.5.4.1 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
