# HG changeset patch # User Gustavo J. A. M. Carneiro # Date 1301265478 -3600 # Node ID 2dde3ecd3a0719a769379e8425d602f8d317063a # Parent 5f49d23b4a74c26b53d8ae70f5fa4d26d3f35814 Modular bindings: Override the core.so module to add an atexit handler that shuts down ns3 before Python diff -r 5f49d23b4a74 -r 2dde3ecd3a07 src/core/bindings/core.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/core/bindings/core.py Sun Mar 27 23:37:58 2011 +0100 @@ -0,0 +1,17 @@ + +# "from _core import *" doesn't work here because symbols starting +# with underscore would not be imported. But they are needed because +# other modules depend on them... +import _core +g = globals() +for k,v in _core.__dict__.iteritems(): + g[k] = v +del g, k, v, _core + + +# Without this, Python programs often crash because Node's are kept +# alive after the Python interpreter is finalized, which leads to +# crashes because some destructors call Python API. +import atexit +atexit.register(Simulator.Destroy) +del atexit