Closed benedikt-voelkel closed 1 year ago
Using SIGTSTP
now (hence catching Ctrl-Z
) to shutdown optimisation.
Ctrl-C
shuts down, as discussed
What do you think @mconcas ?
Using
SIGTSTP
now (hence catchingCtrl-Z
) to shutdown optimisation.Ctrl-C
shuts down, as discussed What do you think @mconcas
Provided that I think we should ultimately follow your taste, what about ^\
(SIGQUIT) instead?
I have it on my ubuntu box to be checked if it is also available on macOS iterm2.
mconcas@box$ stty -a | grep intr
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
One could expect that sending a SIGSTOP leaves the process in a state that can be resumed. Again is common habits vs "just learn that this keys combination is trapped in o2tuner". If signal 3 is unavailable, SIGSTP can also work.
To see if the signal is caught correctly I used this snippet and it was actually getting the ^\
combination.
import signal
import time
def signal_handler(sig, frame):
print(f"Received signal {sig}")
for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGQUIT):
signal.signal(sig, signal_handler)
start_time = time.time()
while time.time() - start_time < 10:
Agreed, using SIGQUIT
now.
So Ctrl-Z
would trigger SIGTSTP
and might put process into bg
as the user might be used to.
Did additional adjustments to avoid flake8
and pylint
complaining about methods being too complex --> some modularisation optimise.py
(which I think might make sense in any case)
introduce Exceptions
catch SIGINT to make sure to find and kill all procs and children
if in optimisation, one can issue a SIGTSTP via Ctrl-Z raises O2TunerStopOptimisation --> workers should catch and simply pass, hence terminate by themselves (currently a timeout of 10s is given from the outside)