﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	notify_on_close	platform	project
650	Add shutdown to session.triggers	Tristan Croll	Tom Goddard	"At the moment I can't find any way for a Python process to know when the ChimeraX session is shutting down, and clean itself up gracefully. This is mildly problematic for my haptic interface code, which has a C++ thread running to handle the device(s) and has some functions that should be run to close this and shut down the device gracefully. I've tried setting it up in a fashion that should theoretically do automatic cleanup:


{{{
class HapticHandler(QObject):
    def __init__(self, session):
        do stuff

    def __enter__(self):
        return self

    def __exit__(self, type, value, traceback):
        self.stopHaptics()


with HapticHandler.HapticHandler(session) as h:
    session.HapticHandler = h

}}}

... but I still need a way to trigger it by deleting the object on quit. At present, closing ChimeraX while the haptic interface is running leads to an inconsequential-but-ugly segmentation fault, and the LEDs on the haptic device remaining on. I'm sure there will be other situations where people will want to run functions on shutdown as well (e.g. automatic saving of the current state of their plugin).
"	enhancement	closed	major		Sessions		fixed		Tristan Croll				all	ChimeraX
