Re: [Maya-Python] Fun fact
I did a quick scan of my codebase and while I know I used it in the past it looks like I'm no longer using executeInMainthreadWithResult anywhere. So it looks like I've been surviving on just doing executeDeferred. And the major places that I am triggering it all seem to fall into a few scenarios, 1) Setting up some GUI stuff during startup. 2) Updating GUIs (which can be a hacky way of getting results back to the main thread) 3) And with some of my callbacks built around the MSceneMessages, because blocking during those events can be super painful. And sometimes maya crashes without it. On Sunday, November 23, 2014 3:58:18 AM UTC-8, Marcus Ottosson wrote: I’ve had good luck with it for simple tasks like updating GUIs. Ah, are you then also calling executeDeferred() from a separate thread, without first wrapping it into a executeInMainThreadWithResult? On 21 November 2014 at 16:39, Robert White robert@gmail.com javascript: wrote: I've had good luck with it for simple tasks like updating GUIs. I also use it as part of my startup sequence for any tasks that need to build/tweak/change maya's default GUIs, because not enough of the maya environment is loaded during userSetup.py's execution. But if you defer those tasks, the idle queue won't be processed until after maya is done loading, and by then if the GUI isn't there, you've got bigger problems. On Friday, November 21, 2014 10:03:14 AM UTC-6, Marcus Ottosson wrote: Thanks, Robert. Makes sense now. Which is why this does work if you just use executeDeferred(), which doesn’t block in the same way. Do you have experience with this across threads? Since it doesn’t return anything it’s a little tricky as a replacement, but if it’s thread-safe then I’ll certainly keep it in mind. -- 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 javascript:. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com https://groups.google.com/d/msgid/python_inside_maya/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com?utm_medium=emailutm_source=footer . For more options, visit https://groups.google.com/d/optout. -- *Marcus Ottosson* konstr...@gmail.com javascript: -- 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/c865f731-dc1c-402b-bacf-9ed9529ea51f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Maya-Python] Fun fact
I’ve had good luck with it for simple tasks like updating GUIs. Ah, are you then also calling executeDeferred() from a separate thread, without first wrapping it into a executeInMainThreadWithResult? On 21 November 2014 at 16:39, Robert White robert.wd.wh...@gmail.com wrote: I've had good luck with it for simple tasks like updating GUIs. I also use it as part of my startup sequence for any tasks that need to build/tweak/change maya's default GUIs, because not enough of the maya environment is loaded during userSetup.py's execution. But if you defer those tasks, the idle queue won't be processed until after maya is done loading, and by then if the GUI isn't there, you've got bigger problems. On Friday, November 21, 2014 10:03:14 AM UTC-6, Marcus Ottosson wrote: Thanks, Robert. Makes sense now. Which is why this does work if you just use executeDeferred(), which doesn’t block in the same way. Do you have experience with this across threads? Since it doesn’t return anything it’s a little tricky as a replacement, but if it’s thread-safe then I’ll certainly keep it in mind. -- 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/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com https://groups.google.com/d/msgid/python_inside_maya/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com?utm_medium=emailutm_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/CAFRtmOBU%3DPmn1remoH2La_rjWOiCke%2BkCnaROc4BY%3DWMv%2BdqWw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Maya-Python] Fun fact
This locks up Maya. from maya import utils def nested_func(): print Hello world def func(): utils.executeInMainThreadWithResult(nested_func) utils.executeInMainThreadWithResult(func) Though I can currently work around it, I can’t quite understand why it would lock up. -- *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/CAFRtmOB0ag9qydyNXS-CqKuhvUf%2BBEAXQxnsqxPhWamF%2BXinyQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Maya-Python] Fun fact
The script or callable object is executed in the main thread during the next idle event. The thread callingexecuteInMainThreadWithResult() blocks until the main thread becomes idle and runs the code. Once the main thread is done executing the code, executeInMainThreadWithResult() returns the result. If executeInMainThreadWithResult() is called from the main thread, then it simply runs the code immediately and returns the result. Because idle events are being used to implement executeInMainThreadWithResult(), it is not available in batch mode. This is from http://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Python-Python-and-threading-htm.html So yeah, basically by nesting these you end up in a situation where you've blocked the main thread, waiting for a result, and because its blocked, it can't process the idle queue to get that result. Which is why this does work if you just use executeDeferred(), which doesn't block in the same way. On Friday, November 21, 2014 9:24:13 AM UTC-6, Marcus Ottosson wrote: Could it be that the inner call is waiting for the outer call to finish, before it can start? And because it never starts, the outer call is never finished? On 21 November 2014 14:06, Marcus Ottosson konstr...@gmail.com javascript: wrote: That would have been acceptable, but it actually locks Maya up when used from within a thread as well. Seems no matter how I twist and turn, that call called from within another call locks Maya up. On 21 November 2014 12:46, Eduardo Grana eduard...@gmail.com javascript: wrote: Hey Marcus, Maybe it's like nuke's similar command, that is only meant to be used inside other threads, and not the main one... Just thinking out loud... Cheers! Eduardo On Fri, Nov 21, 2014 at 9:02 AM, Marcus Ottosson konstr...@gmail.com javascript: wrote: This locks up Maya. from maya import utils def nested_func(): print Hello world def func(): utils.executeInMainThreadWithResult(nested_func) utils.executeInMainThreadWithResult(func) Though I can currently work around it, I can’t quite understand why it would lock up. -- *Marcus Ottosson* konstr...@gmail.com javascript: -- 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 javascript:. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB0ag9qydyNXS-CqKuhvUf%2BBEAXQxnsqxPhWamF%2BXinyQ%40mail.gmail.com https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB0ag9qydyNXS-CqKuhvUf%2BBEAXQxnsqxPhWamF%2BXinyQ%40mail.gmail.com?utm_medium=emailutm_source=footer . For more options, visit https://groups.google.com/d/optout. -- Eduardo Graña www.eduardograna.com.ar -- 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 javascript:. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACt6GrmATAuHuAzhpY%2BXgECBKXGJtGJG2%2BgOwU8KWs6MFVRDPg%40mail.gmail.com https://groups.google.com/d/msgid/python_inside_maya/CACt6GrmATAuHuAzhpY%2BXgECBKXGJtGJG2%2BgOwU8KWs6MFVRDPg%40mail.gmail.com?utm_medium=emailutm_source=footer . For more options, visit https://groups.google.com/d/optout. -- *Marcus Ottosson* konstr...@gmail.com javascript: -- *Marcus Ottosson* konstr...@gmail.com javascript: -- 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/2c5bd8a8-5a77-40c2-87ae-78186e1d7017%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Maya-Python] Fun fact
Thanks, Robert. Makes sense now. Which is why this does work if you just use executeDeferred(), which doesn’t block in the same way. Do you have experience with this across threads? Since it doesn’t return anything it’s a little tricky as a replacement, but if it’s thread-safe then I’ll certainly keep it in mind. -- 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/CAFRtmODwguT7K1okWYhuCyCnALCB1S0G2%3DCAG1j2hR8Sr%3DUsKQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Maya-Python] Fun fact
I've had good luck with it for simple tasks like updating GUIs. I also use it as part of my startup sequence for any tasks that need to build/tweak/change maya's default GUIs, because not enough of the maya environment is loaded during userSetup.py's execution. But if you defer those tasks, the idle queue won't be processed until after maya is done loading, and by then if the GUI isn't there, you've got bigger problems. On Friday, November 21, 2014 10:03:14 AM UTC-6, Marcus Ottosson wrote: Thanks, Robert. Makes sense now. Which is why this does work if you just use executeDeferred(), which doesn’t block in the same way. Do you have experience with this across threads? Since it doesn’t return anything it’s a little tricky as a replacement, but if it’s thread-safe then I’ll certainly keep it in mind. -- 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/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.