Re: Threading in a python extension?



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?

/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.

The day after tomorrow is the third day of the rest of your life.

Attachment: pgpnsqPB14693.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]