I am not 100% sure on windows, but I will make a guess. It might be because
when you are using a pipe you are having the child inherit the file
descriptor (regardless of whether close_fds is used or works on windows).
The child process is looping and writing on stdout (the inherited fd). When
the parent process (Maya) closes it may want to wait for the child to
terminate, but the child won't terminate because it has an open pipe and
nothing has closed it. This would be completely independent from how you
are using a daemon thread. It just means your main process wont wait for
that thread to end, but processes are a different story.

You may want to experimental with trying to ensure you can close the pipe.
Does this have any different behaviour for you on Windows? It may not.

pipe = tempfile.TemporaryFile()
popen = subprocess.Popen(
    ["c:/python27/python.exe", "-u", "-c", child],
    stdout=pipe
)
pipe.close()

If not, it could also be a combination of that and how windows handles
process groups (detach?). Maybe this SO answer might help on Windows in
order to manage the child process when the parent terminates:
http://stackoverflow.com/a/12942797/496445

As a workaround if it becomes to difficult to resolve, you could try
avoiding the inheriting of file descriptors altogether and see if it works
for you by using something like a named pipe, and passing the string name
argument to the child so it can open for reading or create for writing.

Justin


On Thu, Feb 23, 2017 at 6:37 AM Marcus Ottosson <konstrukt...@gmail.com>
wrote:

> Here’s another one I fully expected to work; replacing PIPE with a regular
> file.
>
> import subprocessimport threadingimport tempfile
>
> child = """\
> import time
>
> while True:
>     time.sleep(1)
>     print("child: Still running..")
>
> """
>
> pipe = tempfile.TemporaryFile()
> popen = subprocess.Popen(
>     ["c:/python27/python.exe", "-u", "-c", child],
>     stdout=pipe
> )
>
> My theory was that perhaps Maya has mutilated PIPE for it’s own benefit.
> But alas, still hangs..
> ​
>
> On 22 February 2017 at 17:34, Christopher Crouzet <
> christopher.crou...@gmail.com> wrote:
>
> It's common when doing multiprocessing to have things working when they
> shouldn't in theory (I remember stumbling on a few such examples on
> StackOverflow, and writing many myself). This can be due to the order in
> which operations are being executed on either processes, the size of the
> inter-process messages, and whatnot. This also makes debugging a pain
> because reproducing some issues can be based on luck. So if I were you, I
> wouldn't put too much weight on different behaviours coming from other
> softwares.
>
>
> On 23 February 2017 at 00:27, Marcus Ottosson <konstrukt...@gmail.com>
> wrote:
>
> That sounds logical, but the theory doesn't hold when considering it works
> with Python standalone and with Houdini. :(​
>
> --
> 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_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBX--vbvpOzUDP%2BsiX04MpT-yBMaj6DXwao2sk%3DFz6nPw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBX--vbvpOzUDP%2BsiX04MpT-yBMaj6DXwao2sk%3DFz6nPw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Christopher Crouzet
> *https://christophercrouzet.com* <https://christophercrouzet.com>
>
> --
> 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_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CANuKW51e42hnVhzWTYGMuBy49pRxLQWyU6VSK_nQtno1vzUq2Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CANuKW51e42hnVhzWTYGMuBy49pRxLQWyU6VSK_nQtno1vzUq2Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> *Marcus Ottosson*
> konstrukt...@gmail.com
>
> --
> 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_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODENpMQFw9U7Q7fugFmPsaFWR3jKjMfZas-pXf1saAw3g%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODENpMQFw9U7Q7fugFmPsaFWR3jKjMfZas-pXf1saAw3g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1DhcFksb3tB1cBi4w7hCmEvbzevhEyP9JLBH8Ni9SxSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to