A few things if you’re going to use threads: - I would recommend using `threading` instead of `thread`, as it’s more approachable, and joining your thread if you want to block until the render is done.
t = threading.Thread(target=self.renderWrites) t.start() t.join() - You may want to consider moving the thread target function off of your dialog class, and just passing the Write node(s) to it via the Thread object. - There’s no reason to use `nuke.executeInMainThreadWithResult` unless you actually need to get a return value. - You need to pass the function and write node through `nuke.executeInMainThread` separately. Otherwise, you’re just calling `nuke.execute(writeNode)` and passing the result of that (which is probably None) to `nuke.executeInMainThread`. nuke.executeInMainThread(nuke.execute, args=(writeNode,), kwargs={'continueOnError':True}) - A more idiomatic way to handle exceptions: try: # Something except Exception as e: print 'ERROR: %s' % e # Or whatever you want to do Hope this helps. -Nathan From: Richard Bobo Sent: Thursday, April 24, 2014 12:22 PM To: Nuke Python discussion Subject: Re: [Nuke-python] Execute Write from Python panel Simon, Since I’ve never tried to do coding for a separate thread, I thought I’d give it a try: http://pastebin.com/niEV5FPF My version has some of the very same elements as Mitja’s does. And, my code works -- *most* of the time... ...However, sometimes it gets a... "TypeError: expected callable object, NoneType found” ...and sometimes it gets a… “TypeError: ‘NoneType’ object is unscriptable” ...and sometimes it gets a… “RunTimeError: Cancelled” So, not too reliable!! (8^P If my co-worker Python-guru-friend was here today, I’m sure he could help me debug the problem. Perhaps someone else here could help…? So close, yet, so far... Rich Rich Bobo Senior VFX Compositor Armstrong White Email: rich.b...@armstrong-white.com http://armstrong-white.com/ Email: richb...@mac.com Mobile: (248) 840-2665 Web: http://richbobo.com/ "What you can do, or dream you can do, begin it; boldness has genius, power and magic in it." - Johann von Goethe On Apr 24, 2014, at 3:08 AM, Simon Björk <bjork.si...@gmail.com> wrote: Hi Mitja, thanks for the reply. I tested you code, but unfortunately I still get the "I'm already executing something else" error. Does it work for you? Best regards, Simon 2014-04-24 8:19 GMT+02:00 Mtja Müller-Jend <filmk...@gmx.de>: Hi Simon, try to use threading to execute the node: http://pastebin.com/06azNCzx Cheerz, Mitja Am 4/23/2014 11:54 PM, schrieb Simon Björk: I'm trying to execute a Write node from a Python panel, but I'm not having any luck. As I try to exectute the render I get a RuntimeError: I'm already executing something else. One solution would be to use a Nuke panel instead, but I would really need a Python panel for this script. See short example script here: http://pastebin.com/NzStQNhk. I would really appriciate some help on this. Best regards, Simon _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python -------------------------------------------------------------------------------- _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python