Hi Nathan,

Thanks for your response.
The function I am calling does contain Nuke-specific code. 
It reads in the sequences when they are finished rendering (simple loop with 
create read node with some values set)
When I render locally and call it with the 'after render' function, it works 
fine.
I tried the nuke.executeInMainThread() but to no avail.

def postRenderRead(writes, readnode, startframe, endframe):
    for w in writes:
        w['selected'].setValue(False)
        read = nuke.createNode('Read') 
        read['file'].setValue(w['file'].getValue()) 
        read['xpos'].setValue(w['xpos'].getValue()) 
        read['ypos'].setValue(w['ypos'].getValue() + 180)
        read['format'].setValue(readnode['format'].value())
        read['colorspace'].setValue(w['colorspace'].value())
        read['first'].setValue(startframe.value()) 
        read['last'].setValue(endframe.value()) 
        read['origfirst'].setValue(startframe.value())
        read['origlast'].setValue(endframe.value())
        read['selected'].setValue(True)

Thanks again,

Jack



Message: 2
Date: Wed, 20 Jun 2012 15:18:01 -0700
From: Nathan Rusch <nathan_ru...@hotmail.com>
Subject: Re: [Nuke-python] using threading.Timer() to check if files
        exist
To: "Nuke Python discussion" <nuke-python@support.thefoundry.co.uk>
Message-ID: <bay153-ds19a27fce9898f2e8a8f012f3...@phx.gbl>
Content-Type: text/plain; charset="utf-8"

Are you calling Nuke-specific code when it crashes? If so, you probably need to 
call it using nuke.executeInMainThread(). Give that a try, and if it doesn’t 
work, can you post an example of the types of calls you’re making when it 
crashes?

-Nathan



From: Jack Simpson
Sent: Wednesday, June 20, 2012 3:13 PM
To: nuke-python@support.thefoundry.co.uk
Subject: [Nuke-python] using threading.Timer() to check if files exist

Hi,

I'm having a problem with the threading.Timer() function.

I've written a little class which runs after I've submitted a job to the farm.
It checks the directory of the write node(s) to see if the file exists / has 
been rendered.
I run the timer to check it every 20 seconds until it completes. It check 
nicely every 20 seconds and gives me correct feedback.
However, when it does complete, Nuke crashes and I get an error in the terminal 
which includes:

"QObject::setParent" Cannot set parent, new parent is in a different thread"
"QObject::startTimer: QTimer can only be used with threads started with QThread
"Cannot queue arguments of type 'Animation_Event'"
"Make sure 'Animation_Event' is registered using qRegisterMetaType()"

These errors and crash only occur when the files have finished rendering and I 
try to pass another function. Even if I use a try-except.

Here's a simplified snippet of my code:

class PostRender:
    def __init__(self, writenodes, args):
        get args
        print some feedback
        self.completed = []

    def exists(self):
        for w in writes:
            if w in self.completed:
                continue
            if all(framerange in w exists):
                print w + ' node has finished rendering'
                self.completed.append(w)
            else:
                print w + ' node is still rendering'
        self.wait()

    def wait(self):
        if len(writenodes) == len(self.completed):
            #Crashes here and produces terminal errors
            try:
                print "Rendering complete"
                do another function()
            except:
                return
        else:
            myTimer = threading.Timer(15, self.exists())
            myTimer.start()



I'm new-ish to Python and have never used the threading module before.

I would be so grateful for any help / light-shedding on this topic.

Thanks,

Jack

Nuke 6.3v3
Windows 7 64bit
16GB RAM
16Core CPU



_______________________________________________
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

Reply via email to