how to kill maya started wiith subprocess

96 views
Skip to first unread message

ynedelin

unread,
Oct 16, 2014, 9:06:55 PM10/16/14
to python_in...@googlegroups.com
hey guys,
here is the code

a = subprocess.Popen("maya", stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
a.kill()

it does not work.

I need to start second Maya instance and then shut it down from first Maya instance

Second Maya starts fine but then Popen.kill() does not work. What am I missing?

Thanks
Yury

Justin Israel

unread,
Oct 16, 2014, 11:30:07 PM10/16/14
to python_in...@googlegroups.com
When you say it does not work, do you mean the second Maya window does not visually close down, or that you still detect that the pid is alive? Because you are using pipes for stdin/stdout/stderr, you need to make sure you wait on the child:

a.kill()
a.wait()

After that, the child pid should disappear. Do you actually need the 3 pipes?


--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/59b59367-5558-45e8-acc5-8979e76a304b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Asi Sudai

unread,
Oct 27, 2014, 12:20:54 AM10/27/14
to python_in...@googlegroups.com
Like Justin asked, after you send the Popen.kill() can you see the process still running?

Also did you try running mayapy instead of maya? I'm not sure what you're trying to do,
but mayapy could process what ever you need and then quit, so you won't need to "kill" it. maybe that can work for you?

ynedelin

unread,
Oct 29, 2014, 1:44:03 PM10/29/14
to python_in...@googlegroups.com
Hey guys thanks for the reply.
Justin, sorry I did not see your reply earlier.
Yes Window does not close. with the kill().
The reason I am opening all three pipes is because we run Maya using a tool that sets up different environments based on the job and software versions. This tool also messes around with standard outputs. but even when I start Maya outside of the tool, with default machine envs kill() still does not work.

I did find a way to do it with this:

import subprocess
handle = subprocess.Popen("", shell=False)
subprocess.Popen("taskkill /F /T /PID %i"%handle.pid , shell=True)
  
Thanks

Justin Israel

unread,
Oct 29, 2014, 2:47:31 PM10/29/14
to python_in...@googlegroups.com

Then I don't know. Must be a Windows specific problem. In my previous email, I was addressing that the Maya pid hangs around because you did not wait on the child process. But the window would still close.
If the kill does absolutely nothing for you and the window doesn't close, then somehow the signal isn't reaching the app. Do you launch Maya from some sort of wrapper?

--
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 python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages