If I am not mistaken, when a parent process is trying to exit normally,
that is with no exception or such forced termination, then it needs to wait
for all of its child processes to be joined. If one of them is blocked,
then it won't join.


On 23 February 2017 at 00:13, Marcus Ottosson <konstrukt...@gmail.com>
wrote:

> Thanks Christopher.
>
> Maybe readline() is one of these, meaning that it won’t return until it
> receives something, which might never happen in your case after exiting
> Maya?
>
> That’s right, readline() blocks until something is passed, via send() in
> this case. The for line in iter(out.readline, b""): is an infinite loop
> in this case, but as with any infinite loop in a thread I would have
> expected it to break when the thread is shutdown.
>
> For example, this works fine.
>
> import sysimport timeimport subprocessimport threading
> def _listen():
>     while True:
>         print("Still running..")
>         time.sleep(1)
>
> thread = threading.Thread(target=_listen)
> thread.daemon = True
> thread.start()
>
> Both cases also work well in Houdini, and standalone in a vanilla Python
> process. This symptoms seem highly Maya specific, though I suspect it’s
> only more sensitive to something I’m doing wrong. Such as shutting down a
> thread that is waiting to hear back from the OS about a read from a file.
>
> What’s more, in Maya 2016+ Maya unfreezes as soon as I close the external
> terminal that appears. With 2015 it does not.
>
> Mystery.
> ​
>
> On 22 February 2017 at 17:00, Christopher Crouzet <
> christopher.crou...@gmail.com> wrote:
>
>> Disclaimer: this might be totally unrelated to your problem! :)
>>
>> A common source of deadlocks when using the `multiprocessing` module (or
>> anything related to IPC) comes from calling receiving/sending functions
>> that are blocking. Maybe `readline()` is one of these, meaning that it
>> won't return until it receives something, which might never happen in your
>> case after exiting Maya?
>>
>> A common solution is to wrap the body of the process function
>> (`_listen()` in your case) into an infinite loop and then receive any
>> incoming message only if the inter-process connection is not empty. The
>> infinite loop is exited when the process receives a sentinel/stop message
>> (usually sent from the parent process) to tell it to quit.
>>
>> Not sure if this can be applied to your code though.
>>
>>
>> On 22 February 2017 at 23:22, Marcus Ottosson <konstrukt...@gmail.com>
>> wrote:
>>
>>> close_fds isn’t supported on Windows apparently.
>>>
>>> # ValueError: close_fds is not supported on Windows platforms if you 
>>> redirect stdin/stdout/stderr #
>>>
>>> DETACHED_PROCESS didn’t work either unfortunately, but it was worth a
>>> shot. I feel it must be related to this somehow. I’ve tried
>>> CREATE_NO_WINDOW and CREATE_NEW_PROCESS_GROUP as well without avail.
>>>
>>> Here’s
>>> <https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85>.aspx)
>>> all possible creation flags for reference.
>>>
>>> Any other ideas?
>>>
>>> Best,
>>> Marcus
>>> ​
>>>
>>> --
>>> 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/ms
>>> gid/python_inside_maya/CAFRtmOATTheY4DsCQbrLugUQxJgq7OSyNdHT
>>> UY%3Db%3DWvU1kZ_HQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOATTheY4DsCQbrLugUQxJgq7OSyNdHTUY%3Db%3DWvU1kZ_HQ%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/ms
>> gid/python_inside_maya/CANuKW523MnX4g3AOATrFuqajJb6w4S1p2y5K
>> 2ATqd89Qwpfoaw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CANuKW523MnX4g3AOATrFuqajJb6w4S1p2y5K2ATqd89Qwpfoaw%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/CAFRtmOCzbHgea%3DDTpXB4Haf0q0z%
> 3DDHUNAjAimZMHjae_KTh90A%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCzbHgea%3DDTpXB4Haf0q0z%3DDHUNAjAimZMHjae_KTh90A%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/CANuKW52yaEBwSkLJ%3D08pWtTU9brtsbiKV-ZhigU-NEBEBU7xoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to