Hi all,
I’d like something like this.
1. Maya is launched
2. A child process is launched; via e.g. subprocess.Popen
3. Upon exiting Maya, I’d like the child process to be killed
Ideally, it dies no matter how the parent died; be it normally or when
crashing. And ideally, it’d be cross-platform, and not rely on third-party
module(s), though that’s flexible.
Here’s what I’ve got at the moment.
import atexitimport subprocess
proc = subprocess.Popen(["python"], creationflags=subprocess.CREATE_NEW_CONSOLE)
def kill_child():
proc.kill()
atexit.register(kill_child)
This works standalone, and in Nuke, but not in Maya. It also doesn’t run
when a process is force-quitted/crashed.
So I went a little deeper, looking into OS-specific methods of doing it and
found this for Windows.
http://stackoverflow.com/a/23587108/478949
Which works, but relies on a library 25mb in size and quite elaborate
bundling requirements.
So then I came across this, which provides an example (at the end) that I
can’t quite wrap my head around, but seems to do what I want.
http://stefan.sofa-rockers.org/2013/08/15/handling-sub-process-hierarchies-python-linux-os-x/
But, I can’t successfully adapt it; mainly because I simply don’t
understand it well enough. So I was hoping to get some pointers here,
either about how to adapt it to my scenario or suggest alternatives.
Any ideas?
Best,
Marcus
--
*Marcus Ottosson*
[email protected]
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAvVFGyqZskG8rHiaKB94tusbfoecjNT5NDtC2psfMzJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.