|
Threading on win32: msg#00150gnome.gtk+.python
Hello everyone, I've recently had reason to investigate how to do asynchronous notification from worker-threads to a main-thread (which handles all gtk related function calls). After searching the web and mailing-lists for pygtk for examples on this topic I found out about the following possibilities: 1. Using gobject.io_add_watch() to watch a filehandle for activity. There are several variations on this one: 1.1 Use a temporary file. (Doesn't work on windows.) 1.2 Use a AF_INET socket. (Does work on windows, but many "personal firewalls" get suspicious about it, so an alternative solution is probably preferred.) 1.3 Use os.pipe(). (This uses an extra thread per fd, due to glib's gio_channel stuff, but otherwise should work fine.) 2. Lock the gdk-lock inside worker-thread and schedule an function to be called within main-thread using gobject.idle_add() . 3. Use the gsource-module to make pygtk able to listen to a win32 event. It can be found here: http://www.daa.com.au/pipermail/pygtk/2004-February/006961.html I have briefly tested this technique, but didn't get it to work reliably. This otherwise seems like a very good solution. I've written a test-program which shows the points 2 and 1.3. Both work fine on my linux installation (debian unstable, python 2.3.5, pygtk 2.4.1), however the example using pipes hangs when run in windows (windows xp, python 2.3.4, pygtk 2.4.1). Anyway, I've found a solution (point 2) which works reliably for me. Maybe it would be good to document that it is not possible to use os.pipe() with the gobject.io_add_watch() function on windows. Any alternative solutions to the original problem apart from the ones listed above would be greatly appreciated. //Hugo
pygtk mailing list pygtk@xxxxxxxxxx http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Gnome-keyring: 00150, Guillaume Proux |
|---|---|
| Next by Date: | Re: Verifying Entry inputs: 00150, Christian Reis |
| Previous by Thread: | licensing questioni: 00150, Sorin C. |
| Next by Thread: | Re: Threading on win32: 00150, Tim Evans |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |