Thanks Frank, that's it!
On 14 Aug, 2012,at 08:25 PM, Frank Rueter <fr...@beingfrank.info> wrote:
have you checked the python dev guide?
http://docs.thefoundry.co.uk/nuke/63/pythondevguide/threading.html?highlight=thread
You probably want to check out nuke.executeInMainThread()
On 15/08/12 3:15 PM, Andreas Frickinger wrote:Hi,
I've looked through some similar threads but couldn't really find the answer to my question. Is it possible to launch a command with subprocess.Popen and get back stdout on a line-by-line base without freezing the MainThread?
Here is a simple example:
proc = subprocess.Popen(['ls','-l'], stdout=subprocess.PIPE)
while True:
line = proc.stdout.readline()
if not line: break
print line
It basically freezes the GUI for the time it's in the while statement. I tried to do this via threading, which seems to ALMOST work:
import subprocess
import threading
proc = subprocess.Popen('ls -l', shell=True)
def test(input):
print input
def getResult(proc):
while proc.poll() == None:
if proc.poll() == 0:
break
threading.Thread(name='MainThread' , target=test, args=('test output',)).start()
threading.Thread( None, getResult, args=(proc,) ).start()
This seems to do what I'm expecting, the problem is that I can't get back to the main thread and therefore cannot open up nuke.message or nuke.display as this is only possible from the Main Thread.
Any ideas?
thanks,
andy_______________________________________________ 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