On Tue, Jun 22, 2004 at 08:14:22AM +0100, Prash wrote:
> I started out to code threading but when I finished and ran it - I
> realized that  redhat had compiled pygtk without threading support
> (another one of their "atrocities"). I opted for laziness and explored
> generators but I realized I had already coded the algorithm to call many
> functions and generators didn't make any sense in this case.

Generators won't *always* solve the problem; for instance, when using
any sort of blocking call into a C extension, nothing apart from threads
is going to allow the mainloop to run concurrently anyway.

Generators are more coarse-grained than threads, in general, since you
choose at which points you want to yield control. That's intentional.

> Take the example: I have to call a function to display newsfeed every
> hour - so I add a timer event. Now that newsfeed function instantiates
> another class and calls its function to fetch and display data in a
> textview. Now to call that function in a timeout_add again and adding
> generator support didn't appeal to me at all.
> 
> So I'm adding gtk.main_iteration() and hoping it would work smoothly.

If you have the option to insert this in your code, it's an alternative
(though IMO it usually violates cohesion IMHO since you have UI code in
your application-specific bits). It has the same coarse-grained
semantics that generators do, however.

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to