On Wed, Jun 21, 2006 at 16:08:36 -0700, Adam Hooper wrote: >On Wed, 2006-21-06 at 22:53 +0100, Magnus Therning wrote: >> On Sun, Jun 18, 2006 at 12:32:52 +0200, Frederic Peters wrote: >> >Magnus Therning wrote: >> > >> >> Does anyone have any examples of multi-threade extensions written in >> >> Python? >> > >> >Nope but multi-thread is perhaps not necessary, PyGTK FAQ has a good >> >suggestion about using gobject.idle_add and python enumerators. I >> >have been using this trick in a few pygtk apps to keep them >> >responsives while not using threads and have been very happy with it. >> > >> > http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq23.020.htp >> >> Isn't there an error in that recipe? >> >> my_task() will return a new generator each time it's called so the >> following code wouldn't do what's intended, right? >> >> def on_start_my_task_button_click(data): >> gobject.idle_add(my_task().next, data) >> >> I think what's intended is: >> >> def on_start_my_task_button_click(data): >> task = my_task() >> gobject.idle_add(task.next, data) >> >> Or did I miss something? > >You're on the right track, but missing something. The function which is >being passed in gobject.idle_add() is the generator's ".next()" method. >So *that* method will be called time and time again until it returns >false. What I really missed was my brain. It seemed to have stepped out at the moment I wrote that email. I will not even try to explain how I arrived at that question... /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus therning org Jabber: magnus therning gmail com http://therning.org/magnus Software is not manufactured, it is something you write and publish. Keep Europe free from software patents, we do not want censorship by patent law on written works. Never be afraid to try something new. Remember, amateurs built the ark; professionals built the Titanic. -- Anonymous
Attachment:
pgp2wG5L7lp64.pgp
Description: PGP signature