Re: [pygtk] Wait until a thread is ended
On Thu, Sep 28, 2006 at 09:16:20PM +0200, Adolfo González Blázquez wrote: > I would like to know if someone can point me a solution to make a > function run as a separate thread, and wait until it is ended, without > blocking the gui. > In my application, i'm getting a long file listing using glob(), and i > want this function to run as a thread, so the user can stop it using a > button in the gui (right now, the gui freezes till glob is ended), and > then run another function to fill the treeview (this now works without > blocking the gui, using generators). . Use a callback to handle the result and call it from your thread with gtk.idle_add(). Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Wait until a thread is ended
abel deuring napisał(a): > t = threading.Thread(target=threadfunction) > t.start() > > while t.isAlive(): > print "waiting for thread" > time.sleep(1.2) Other idea is waiting until threading.activeCount drops below 2, i.o.w. you get only one active thread and this is a main thread (this may be of some use if you spawn more than one worker thread). See: http://docs.python.org/lib/module-threading.html -- Jarek Zgoda http://jpa.berlios.de/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Wait until a thread is ended
Adolfo González Blázquez wrote: > Hello, > > I would like to know if someone can point me a solution to make a > function run as a separate thread, and wait until it is ended, without > blocking the gui. > > In my application, i'm getting a long file listing using glob(), and i > want this function to run as a thread, so the user can stop it using a > button in the gui (right now, the gui freezes till glob is ended), and > then run another function to fill the treeview (this now works without > blocking the gui, using generators). . > > Any idea will be really appreaciated. import threading import time def threadfunction(): # thread: do nothing for ca. 10 seconds stoptime = time.time() + 10.0 while time.time() < stoptime: print "thread: running" time.sleep(1) print "thread: ending" t = threading.Thread(target=threadfunction) t.start() while t.isAlive(): print "waiting for thread" time.sleep(1.2) HTH Abel ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Wait until a thread is ended
Hello, I would like to know if someone can point me a solution to make a function run as a separate thread, and wait until it is ended, without blocking the gui. In my application, i'm getting a long file listing using glob(), and i want this function to run as a thread, so the user can stop it using a button in the gui (right now, the gui freezes till glob is ended), and then run another function to fill the treeview (this now works without blocking the gui, using generators). . Any idea will be really appreaciated. Thanks in advance! -- adolfo signature.asc Description: Esta parte del mensaje está firmada digitalmente ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/