You might find the techniques in this topic helpful. The same life cycle considerations for background threads apply to any kind of jython class objects you try to persist. Be aware that you cannot leave a jython class instance in any global scope through a scripting restart. That leaks a big chunk of memory, and your class object keeps running the old code.