nekohayo / specto

Automatically exported from code.google.com/p/specto
0 stars 0 forks source link

threading #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Specto currently has only one process/thread to manage the user interface,
the watches, and everything else. This is bad because:
- if something crashes, everything crashes
- the user interface freezes; often
- it's ugly

Ideally, watches should be able to run simultaneously, in parallel instead
of all depending on each other's completion. The user interface should be
separate from them and react only when needed.

Please discuss of the best ways we could achieve this. Simplicity is a
great plus.

See also:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878
http://www.burtonini.com/blog//computers/python-2006-09-11-21-30
http://www.oreillynet.com/onlamp/blog/2006/07/pygtk_and_threading.html

Original issue reported on code.google.com by nekoh...@gmail.com on 12 Nov 2006 at 9:58

GoogleCodeExporter commented 9 years ago

Original comment by nekoh...@gmail.com on 15 Nov 2006 at 12:08

GoogleCodeExporter commented 9 years ago
Ok.  Here's one option:

Watches don't need to do any UI.  At all.  So why don't we just spool off one 
thread
per watch (using one of those nifty "threaded" decorators), since it doesn't 
matter
that gtk+ isn't threadsafe.  If the watch has something to say (there's an 
error, the
watch has been updated, etc), it should signal the core, and the core can do 
whatever
updating it wants/needs to do in its very own cosy little GTK+ thread.

Code, as I see it, would look something like:
#Oops, Signal error
self.specto.raise_error(self, 'Bad username/password')

#We're updated.  Notify core
self.specto.add_update(self, "Your email account, <b>%s</b>, has <b>%d</b> new 
mail."
% (self.name, self.newMsg-self.oldMsg))

These would add data to some sort of (probably mutex'd) list, then send a 
signal to
the main thread.  It's then the main thread's responsibility to do whatever 
displaing
needs to be done.

Original comment by chalsero...@gmail.com on 23 Nov 2006 at 4:25

GoogleCodeExporter commented 9 years ago
Fixed in revision 34!!!

Original comment by woutclym...@gmail.com on 15 Dec 2006 at 4:59

GoogleCodeExporter commented 9 years ago

Original comment by nekoh...@gmail.com on 1 Jul 2007 at 2:25

GoogleCodeExporter commented 9 years ago

Original comment by nekoh...@gmail.com on 18 Mar 2008 at 1:50