This is just a thought triggered by an observation.
We noticed that when a SLURM job is scanceled that is currently inside a tempfile.TemporaryDirectory context manager, the context is not unwound (leaving behind a temporary directory that could potentially be large and which could potentially accumulate on nodes over time).
Apparently, this is expected behavior as the __exit__ block only runs during normal Python exception unwinding.
Now, I believe as an executorlib user one can work around this by catching the SIGTERM signal directly in the corresponding Python code and raising an exception instead, allowing the code to unwind. Or perhaps executorlib could do this for us, such that cancelling a slurm job is seen by the Python code as an exception being raised rather than a SIGTERM.
I'm not sure whether it is a good idea for executorlib to do this sort of transformation, just wanted to mention the idea
@Gitdowski
This is just a thought triggered by an observation.
We noticed that when a SLURM job is
scanceled that is currently inside atempfile.TemporaryDirectorycontext manager, the context is not unwound (leaving behind a temporary directory that could potentially be large and which could potentially accumulate on nodes over time).Apparently, this is expected behavior as the
__exit__block only runs during normal Python exception unwinding.Now, I believe as an executorlib user one can work around this by catching the
SIGTERMsignal directly in the corresponding Python code and raising an exception instead, allowing the code to unwind. Or perhaps executorlib could do this for us, such that cancelling a slurm job is seen by the Python code as an exception being raised rather than aSIGTERM.I'm not sure whether it is a good idea for executorlib to do this sort of transformation, just wanted to mention the idea
@Gitdowski