[pygtk] Threading problem using pygtk on Win32
Alexandre Fayolle
Alexandre.Fayolle@logilab.fr
Thu, 2 Nov 2000 15:55:06 +0100 (CET)
Hello,
I'm using happily pygtk to develop Horn the user interface for Narval
(http://www.logilab.org). It runs very well under Linux, but I'm having
big troubles getting something under Windows. It looks like there's
something wrong with the thread support in pygtk win32 edition. I checked
Hans Breuer patch over pygtk 0.6.4 and it does look like there's a known
issue with threading in the patch, from the comments I saw.
If we cut down to the skeletton of the app, the implementation is
something equivallent to:
----------------------8<-----------------------
from gtk import mainloop, timeout_add
import time
import thread,Queue
queue = Queue.Queue(10)
def ping_thread():
while 1:
t = time.time()
print 'ping',t
queue.put_nowait(t)
time.sleep(0.7)
def pong():
try:
while 1:
t0 = queue.get_nowait()
t1 = time.time()
print 'pong',t1, t1-t0
except:
return 1
thread.start_new_thread(ping_thread,())
timeout_add(1000,pong)
mainloop()
---------------------8<----------------------------
This works fine under linux, but under windows (winnt4.0, runnning on a
P133), I get pongs comming with a 9 seconds lag. So my question is:
* is it just because my NT box is waaaaaay to slow ?
* has it something to do with lines 31-32 of the patch which state:
+#if defined (_MSC_VER)
+#undef WITH_THREAD /* no thread support on win32 yet */
In that case what would be required to implement the thread support on
win32 ? I'm not yet very familiar with the innards of the python bindings
of gtk nor with the win32 port of GTK+, but I'm ready to get my shirt wet,
since I really need this feature. Any help/suggestion welcome.
Alexandre Fayolle
--
http://www.logilab.com
Narval is the first software agent available as free software (GPL).
LOGILAB, Paris (France).