plugins/python: only deinit interpreters when sudo unlinks the plugin

This only happens when sudo unloads the last python plugin.
The reason doing so is because there are some python modules which
does not support importing them again after destroying the interpreter
which has imported them previously.

Another solution would be to just leak the interpreters (let the kernel
free up), but then there might be some python resources like open files
would not get cleaned up correctly if the plugin is badly written.

Tests are meant to test the scenario sudo does, so I have modified them
to generally do not unlink but only a few times (~per plugin type) so it
does not use 48 interpreters (one gets started on every plugin->open) and
it is visible at least which type of plugin fails deinit if there is an
error.
This commit is contained in:
Robert Manner
2020-02-17 16:16:04 +01:00
committed by Todd C. Miller
parent 8a9218d161
commit 27de7dd24d
6 changed files with 124 additions and 47 deletions

View File

@@ -1,4 +1,3 @@
importing module: SRC_DIR/example_debugging.py
Extending python 'path' with 'SRC_DIR'
Closing: 0 python plugins left open
Closing: deinit python interpreter
Deinit was called for a python plugin