Modular bindings: Override the core.so module to add an atexit handler that shuts down ns3 before Python

This commit is contained in:
Gustavo J. A. M. Carneiro
2011-03-27 23:37:58 +01:00
parent 35a81dd4e4
commit 3cdd433fbd

17
src/core/bindings/core.py Normal file
View File

@@ -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