On 08/03/2017 at 02:37, xxxxxxxx wrote:
I'm not sure, if you try to use a thread from a Python script (in the following I use the term script only for code called from the Script Manager) or from a Python plugin (like CommandData).
In general it's not a good idea to create a thread from inside a script. The thing is, who owns the thread after the script is finished. Even if using a global variable, we have nowhere documented, what happens to global variables after a script finished (for good reason). So the behavior is already undocumented. But what happens, if the script is run for a second time. If not before, at least at this point, nobody will be storing a reference to this thread anymore, as the script will overwrite the globals.
The better way to do something like this, is to implement a CommandData plugin (other types might work as well, depending on your needs and actual use-case). There you have a "resident" class, which can host the thread (i.E. store a reference to the thread in a member variable). And then you can also implement PluginMessage() in order to react to Cinema quitting.
Just for completeness for future readers:
In Python docs: Threading, BaseThread
In C++ docs there are manuals on different areas of threading and Plugin Functions (like PluginMessage())