You can check the ghenv.Component.Locked
property. You might also be interested in the GhPython SDK mode slideshow and examples I posted over here, sounds like many of the methods used there would be relevant to you. Also, if the data doesn’t need to be globally accessible, there are simpler ways of making persistent variables in GhPython. Edit: Here’s a SDK mode example too:
240712_PersistentVariable_SDKMode_00.gh (5.6 KB)
Edit II:
I don’t think that is possible. When the component is disabled it can’t do anything, I think…