slapgrid: Process promises with SR python
slapos node (
slapgrid) launch each instance's promises using the Python installed by the SR (the Python for and by which the promises are installed).
This means that when computing the promises a Python subprocess is started for each partition. This is not as good as a single Python process (but then we have version problems), but not as bad as a Python process per promise.
To propagate exceptions to the calling
slapos node process, I take advantage of the fact that the logger only uses
stderr: I redirect
sderr in case the promise happens to print things to
stdout directly instead of using the logger, and now that
stdout is unused I just print the error message to
stdout and use the returncode to distinguish between
PromiseError and other exceptions.
A possible optimisation would be to share the same python process for all partitions that share the same python. This would be difficult in a real
slapos node because each partition has a different user and the SR python should not be run as root, but could be used inside
Also do some general refactoring along the way.