Ah! It looks like that is working…haha. So, each time I run the code ‘nuke.executeInMainThreadWithResult’ Nuke is starting a thread? I thought it only executes a piece of code in the main thread and that you call a new threat with 'threading.Thread(None, ‘function').start()’.
Thanks! Bram On Jul 28, 2014, at 4:19 PM, Dan Rosen wrote: > Try the for loop inside the thread rather than a thread for each time it > loops. Maybe? > >> On Jul 28, 2014, at 5:57 AM, Bram Buddingh <b...@postoffice.nl> wrote: >> >> Hi everybody, >> >> I am working on a python script that creates more than 25 read nodes with >> approximately 30 timeOffset nodes connected to each of them. So I end up >> with a script containing something like 1000 nodes. This could be extended >> later, depending on the needs. >> >> This is quite compute intensive to run. The main nuke thread/window freezes >> and you don’t know how long you have to wait until it’s finished. I am >> trying to put this in a separate thread with a status bar. The problem is >> that the threaded way is even slower than without putting it in a separate >> thread. To make it a bit clear, I wrote some python lines to demonstrate >> what I am trying to do: >> >> >> -------------------------------------------------------------------------------------------- >> import threading >> >> ### option 1: even slower than option 2 ### >> def createBlurNodes(): >> task = nuke.ProgressTask("Create") >> task.setMessage("Creating blur nodes") >> >> for i in range(1000): >> nuke.executeInMainThreadWithResult(nuke.createNode, args = ('Blur', >> '', False)) >> task.setProgress(i/10) >> >> threading.Thread(None, createBlurNodes).start() >> >> >> ### option 2: slow and I don't have visible feedback about the estimated >> calculation time. Plus nuke is freezing for a couple of seconds, depending >> on your machine specs. ### >> for i in range(1000): >> nuke.createNode('Blur', '', False) >> >> -------------------------------------------------------------------------------------------- >> >> Maybe it’s slow because nuke.createNode is always running in the main thread? >> >> Is this the correct way, or is there a better way to script this? >> Thanks for the help in advance! >> >> Bram Buddingh_______________________________________________ >> 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