Yep, threading!

Something like this untested/pseudo-code:


import threading

def callback_render_done(jobid):
    """Function is executed in main thread, so can alter nodes etc
    """
    print "Job ID is done!"
    for w in nuke.allNodes("Write"):
        w['label'].setValue("blah...")


class FarmMonitor(threading.Thread):
    def __init__(self, jobid):
        """Initialise thread, then store the jobid for use later
        """
        super(FarmMonitor, self).__init__()
        self.daemon = True # Don't prevent Nuke from closing

        self.jobid = jobid

    def run(self):
        """The main thread function. Checks if the job is complete,
        then runs the callback when it is done
        """

        while True:
            if is_render_done(self.jobid):
                nuke.executeInMainThread(callback_render_done, self.jobid)
                return # Ends thread
            else:
                time.sleep(1) # wait before checking again


mon = FarmMonitor(1234)
mon.start()


Same idea applies to updating a PythonPanel, or nuke.ProgressTask()
instance - showing farm-render progress via ProgressTask's is something
I've been meaning to play with for a while..

Nathan Rusch wrote:
> You probably want to do something like farm out the Rush-check
> function to a daemon thread that calls nuke.executeInMainThread at
> intervals to do your GUI updates.
>  
> -Nathan
>
>  
> *From:* Farhad Mohasseb <mailto:[email protected]>
> *Sent:* Monday, February 28, 2011 8:41 PM
> *To:* Nathan Dunsworth <mailto:[email protected]>
> *Cc:* Nuke Python discussion
> <mailto:[email protected]>
> *Subject:* Re: [Nuke-python] Live update in nuke background.
>  
>
> Hey Nathan,
>
> Thanks for the quick reply.
>
> I completely agree with you and for that exact reason I wasn't
> actually planning on putting it on the label at the end. I was merely
> using that as a simple example for my question. A panel will still
> have the same problem as nuke won't release the controls back to the
> user until it is 100% done.
>
> My question I guess is more a how rather than where. How would you
> loop the check rush script or for that matter any loop while releasing
> nukes ui so the artist can continue to work. In anything outside of
> nuke you would just run this in the background. So I want to know if
> something like that is possible within nukes python limitations and if
> so how would you go about it and if not then is there any alternative
> ways? 
>
> Thanks again Nathan! Hope this clarify a bit as to what I'm trying to
> achieve.
>
> Cheers,
> Farhad
>
> On Feb 28, 2011 6:55 PM, "Nathan Dunsworth" <[email protected]
> <mailto:[email protected]>> wrote:
>
> ------------------------------------------------------------------------
> _______________________________________________
> Nuke-python mailing list
> [email protected]
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
> ------------------------------------------------------------------------
>
> _______________________________________________
> Nuke-python mailing list
> [email protected]
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>   

-- 
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au

_______________________________________________
Nuke-python mailing list
[email protected]
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to