Problem: I want to execute a function before ST process terminates. I have successfully used EventListener.on_exit()
, but that is not called if the process is terminated via SIGTERM signal (I’m on Linux).
In order to do so I’ve tried to both register a signal handler and to use atexit
stdlib module, but neither worked. Any advice?
Thanks in advance!
import atexit
import signal
import sublime_plugin
def cleanup(): # <-- never called
...
class InMemoryDBOnExit(sublime_plugin.EventListener):
def on_exit(self): # <-- never called
cleanup()
def sigterm_handler(signum, frame):
cleanup()
atexit.register(cleanup) # <-- doesn't work
signal.signal(signal.SIGTERM, sigterm_handler) # <-- doesn't work