Greetings all,

I'm, err, having threading problems. I've googled through this list,
and indeed as much of the Internet as I can reach, looking for answers
and workaround to no avail. I am still just learning, really, and have
a feeling I've bitten off more than I can chew.

The situation is this:

I am trying to create a gnome applet that checks mail accounts,
displaying the usual stuff.

The files involved are:

gnoptray.py - script that launches the applet

cApplet.py - Module containing the applet class

cAccounts.py - Module containing an 'Account' class. It is built using
(not extending) imaplib and poplib. It stores an internal dictionary
of message headers, can update itself, fetch and delete messages.

guiAccount.py - GTK extensions to the cAccounts.Account class. Creates
a GUI that sets account attributes, such as username, password, etc...

The problem I'm having is with checking mail. I started by creating a
timeout that would call the update() method of a guiAccount object.
Obviously, this freezes the entire UI. I don't really want to update
the GUI while checking... I just want my menus and such to appear
while it's churning away in the background.

So I tried threads... Throwing in gtk.threads_init(), wrapping
gtk.main() in gtk.threads_enter() and gtk.threads_leave() - doing the
same with my time-out callback.

e.g
 ...
    if interval != 0:
        self.timeout_ids[name] = (gobject.timeout_add(interval,
self.check_mail, name))

def check_mail(self, name):
        thread1 = threading.Thread(target=self.accounts[name].update())
        thread1.start()
        return 1


But nothing really worked. The UI still froze until checking was
complete. Is it worth pursuing this path?

I have tried generators, but they did not work as expected. I am now
considering writing a daemon application to do the actual mail
checking - and just feed it into the GUI through an input_add().
Either that or toss out my cAccounts.py module and build a gtk version
of imap/poplib using input_add. Any help would be much appreciated.

Cheers,
_______________________________________________
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