
There’s a great introduction with example at this blog. Definitely familiarize yourself with the subprocess Python module. The trick to running processes invisibly and “asynchronously” lies in the ability to generate background child processes of Maya. (As far as I’m aware it’s impossible to execute any maya.cmds commands from another thread.) You’ll quickly find yourself crashing Maya and getting all sorts of horrible print outs in the console log. I’ve not had a ton of luck with multithreading in Maya. Lastly, we have shown how to terminate a running process(es) using Task Manager, command prompt, and Python packages.The concept of allowing artists to continue working even while a tool is processing has been a guiding principal behind much of my Maya tool development.

We have demonstrated how this is done by running a python.exe process in the background (you can do this with any process). In this article, we discussed how to wake up a process and keep running in the background using Python. In such a case, Image Name is a better option to use. This means that the PID used to kill a task generated by a given app may not work when an app is closed and opened again. The PID changes every time you open the process/app. This option might be needed when closing a task used by another process, for example. It is used to terminate a process forcefully. Note: The /F option issued to the taskkill command is optional. os.system(“taskkill /IM ctfmon.exe /F”).

You can kill running tasks using subprocess or os as follows (note that you need to import these packages):

when using PID run “ taskkill /PID /PID /F“, for example, “ taskkill /PID 11024 /F” to kill CTF Loader.
