Ok I have narrowed the problem down, and I'm hoping somebody knows the solution. Basically I have a pyGTK application, using widgets and all of that. I have stripped all of the gtk objects out except the gtk.main() initializer. I basically want to start a threading process, and still have the main program run while the thread is executing. I have this working only when I have commented out gtk.main(). Try my example code below on your computer as is.
#!/usr/bin/env python
import threading, os
try:
import gtk
import gtk.glade
except:
sys.exit(1)
class CommandOutput(threading.Thread):
def __init__(self, command):
threading.Thread.__init__(self)
self.command = command
def run(self):
os.system(self.command)
print 'Finished background process, should always be printed last.'
class Caller:
def __init__(self):
background = CommandOutput("ls -la /")
background.start()
print 'The main program continues to run in foreground. This should be the first thing printed.'
if __name__ == "__main__":
objCaller = Caller()
#gtk.main()
So if you run this in commandline python test.py it works as expected. However My program requires gtk widgets and objects. so if you Uncomment the last line there (#gtk.main()) and run the command, it waits after printing the one statement. It will Only proceed to execute background.start() when I press "Control + C" to terminate, and it then spews out the ls and then the final print statement.
Could it be because the gtk.main() is recursively ran once called? If so how can I avoid this.
Thanks for any help in advance